note 34582 added to function.array-push
| From: | vitale at students dot math dot unifi dot it | Date: | Thu, 31 Jul 2003 12:28:52 +0000 |
| Subject: | note 34582 added to function.array-push | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-53069@lists.php.net to get a copy of this message | ||
Just to correct example posted by "daevid at daevid dot com" on 14-Mar-2003 01:52.
array_merge renumber numeric keys, thus the key may not be mantained.
Try this code:
function addArray(&$array, $key, $val)
{
$tempArray = array($key => $val);
$array = $array + $tempArray;
}
----
Manual Page -- http://www.php.net/manual/en/function.array-push.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34582
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34582&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34582&report=yes