Похожие чаты

Hello, how do I add one element to a multi-dimensional

array without using array_push?
array_push($md_array["1"], $new_element);

I'm asking this because PHP docs state: Note: If you use array_push() to add one element to the array, it's better to use $array[] = because in that way there is no overhead of calling a function.

4 ответов

7 просмотров

The note already gave you the answer...

Bruno- Автор вопроса
Alfredo Ramos
The note already gave you the answer...

Not for multidimensional arrays. The syntax is $md_array[0][] = ... which was my question

Bruno
Not for multidimensional arrays. The syntax is $md...

Yes, it gave you the answer. $array was just a placeholder for an array, which in your example was $md_array["1"]

Bruno- Автор вопроса
Alfredo Ramos
Yes, it gave you the answer. $array was just a pl...

Sure, I had tried [][] but it wasn't working for another, unrelated reason, and I thought the syntax for accessing multidimensional arrays in php could be different. Plus I wasn't familiar with the feature that I can push a value to an array by assigning it with no defined index ($arr[]). But thanks anyway!

Похожие вопросы

Обсуждают сегодня

@MrMiscipitlick А можешь макрос написать, который будет вычислять смещение относительно переданных меток? Просто .label1-.label2, и вернуть значение.
КТ315
35
Подобного рода ;Следующие три строки это директивы ассемблера, ;которые можно не задавать, т.к.работаем в Visual Studio. ;Символ ";" - это начало однострочного комментария ...
Егор Анелькин
3
А кто-то пробовал, уезжая из Эстонии получить э-рез и продолжить вести предпринимательскую деятельность внутри Эстонии, используя свой OÜ?
Lalalashechki Lalala
51
я не магистр хаскеля, но разве не может лейзи тип конвертнуться в не-лейзи запросив вычисление содержимого прям при инициализации?
deadgnom32 λ madao
100
А еще в перле можно уже @arr1 + @arr2?
Sergei Zhmylove
53
Привет всем. появился вопрос. Разрабатываю сайт, в данный момент он запущен. Хостинг beget. Добавляю на сайт яндекс метрику с помощью полей client-settings (взято отсюда http...
Andrew
2
I arrived here after a Chico Crypto show highlighted the project & the Team - the fact that the Team had a long history of successfully working with household names gave me e...
Banter is Bullish
4
открыть папку в проводнике: 1 - ShellExecute 2 - ExecuteProcess 3 - OpenDocument что лучше выбрать?
Alexey Kulakov
12
Morning people Just seeing the conversation about Mining. It's clear that at this point in time it doesn't look like there is much point to it. But the Hasrate is at a al...
Kenny
4
Только сейчас дошли руки до Orange pi 5. Это нормально что на нем YOLOv5s выдает 1 кадр раз в 2-3 секунды на CPU? Это без оптимизаций и прочих настроек, просто голый запуск че...
Denis
10
Карта сайта