I've got a situation where I need to assign values into an array, potentially several times during code execution. I'm wondering whether more memory is allocated via using array() multiple times, versus assigning into array elements. For example:
For an overwrite, the latter would be logically more efficient if these were real arrays. The former would require a malloc for each int*, while the latter is merely overwriting that of a[x].
In PHP though, there are no arrays, these are all hashtables, and offhand I don't know what type of storage is actually in use. PHP is a surprisingly efficient language in how it deals with things, so I would not be surprised if under the hood both result in the same effect. The only thing that would change that would be if $a is assigned without a reference to another variable, in which case you are guaranteed to malloc more data (since PHP works in copy on write context).