How to write to the first element of an array?
I know reset can return the first element... but you can not use it to write to it.
![]() ![]() ![]() |
|||||||
|
![]() ![]() ![]() |
Anything wrong with If you don't want to overwrite the first element, try "array_unshift": http://www.php.net/manual/en/function.array-unshift.php EDIT: ok, use this for non-numerical keys:
|
|||
|
![]() ![]() |
That's called an "associative array" or a "hash". Technically, it doesn't have an order. You may have an item that you've put in first, but that's only incidental. |
||
|
![]() ![]() |
does this work?
|
||||
|
![]() ![]() |
Do you mean prepend the array with a value?
|
||
|