note 23429 added to function.array-unshift
| From: | TimHyde at C21Technology dot com | Date: | Thu, 18 Jul 2002 09:04:26 +0000 |
| Subject: | note 23429 added to function.array-unshift | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-33241@lists.php.net to get a copy of this message | ||
A simpler way to implement an array_unshift with key=>value pairs (i.e. similar to the example
using array_reverse above) is to use array_merge. i.e.
$arrayone=array_merge(array("newkey"=>"newvalue"),$arrayone);
Obviously you need to take care when adding numeric or duplicate keys.
--
http://www.php.net/manual/en/function.array-unshift.php
http://master.php.net/manage/user-notes.php?action=edit+23429
http://master.php.net/manage/user-notes.php?action=delete+23429
http://master.php.net/manage/user-notes.php?action=reject+23429