Moving key in array
Posted: Tue Feb 08, 2005 12:59 pm
Might there be a function for this... I have tried but I cant find anything
Would like key "a" moved to "c" but not replacing
$foo would now be
Array
(
[0] => b;
[1] => c;
[2] => a;
[3] => d;
)
Thanks in advance
Would like key "a" moved to "c" but not replacing
Code: Select all
$foo= array(a,b,c,d);
$movefrom =0; // the pos of the key in $foo which is "a"
$moveto = 2; // where "a" should be moved to
movekey($movefrom,$moveto);Array
(
[0] => b;
[1] => c;
[2] => a;
[3] => d;
)
Thanks in advance