I figured it out, not what i'd wanted it to be, but it works, if anyone can improve upon it, please let me know.
<?php function array_key_replace($foo,$original,$replacement,$replacement_value) { $bar=array(); foreach($foo as $key=>$value) { if ($key==$original) { $bar[$replacement]=$replacement_value; } else $bar[$key]=$value; } return $bar; } $foo=array("color"=>"blue","fruit"=>"apple","foo"=>"bar"); $foo=array_key_replace($foo,"fruit","car","pinto"); ?> Enjoy! ;) Austin W. Marshall wrote: > 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. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php