Posted by Geoff Berrow on 01/30/07 10:57
Message-ID: <BkFvh.196175$MO2.66573@fe3.news.blueyonder.co.uk> from
David Smithz contained the following:
>>Geoff said:
>> $array['key number 2']=$array['key2'];
>> //optionally
>> unset($array['key2']);
>
>Thanks for this Geoff. Works. However does lose the ordering of my array. Is
>there a way of maintaining the order as I guess the above puts in a new
>element, and then just removes the old one.
>
>How can I as well maintain the order.
It's difficult to advise without knowing exactly what you want to do but
you could make a copy of the array changing the keys as necessary.
foreach($array as $key=>$value){
if($key=="key2"){
$key="key number 2";
}
$temparray[$key]=$value;
}
$array=$temparray;
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
Navigation:
[Reply to this message]
|