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.
The note already gave you the answer...
Not for multidimensional arrays. The syntax is $md_array[0][] = ... which was my question
Yes, it gave you the answer. $array was just a placeholder for an array, which in your example was $md_array["1"]
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!
Обсуждают сегодня