retaining keys in array_splice
| From: | Austin W. Marshall | Date: | Sun, 23 Jun 2002 22:14:16 +0000 |
| Subject: | retaining keys in array_splice | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-103499@lists.php.net to get a copy of this message | ||
I can't seem to figure out how to use array_splice to replace an element while retaining the key... instead it replaces the key with 0
for example...
$foo=array("color"=>"blue","fruit"=>"apple","foo"=>"bar");
array_splace($foo,1,1,array("car"=>"pinto"));
yields...
Array
(
[color] => blue
[0] => pinto
[foo] => bar
)
instead of
Array
(
[color] => blue
[car] => pinto
[foo] => bar
)
...
Is there a quick and dirty way to do this? or does it require chopping the array up into to parts and merging them back together again.