Reply to Re: Replacing key in associative array

Your name:

Reply:


Posted by Rik on 01/30/07 11:53

David Smithz <dave1900@blueyonder.co.uk> wrote:

>
>> Smithz asked:
>>
>>> if there is a key with value "key2", change this key name so it is =

>>> instead
>>> "key number 2" (while maintaining the keys value).
>> Geoff said:
>> $array['key number 2']=3D$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 ne=
w
> element, and then just removes the old one.
>
> How can I as well maintain the order.

http://nl2.php.net/manual/en/function.array-splice.php

-- =

Rik Wasmus

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация