Reply to Re: how to replace an array key and keep the position?

Your name:

Reply:


Posted by ZeldorBlat on 10/05/07 19:16

On Oct 4, 6:22 pm, Ian Hobson <ian.hob...@ntlworld.com> wrote:
> IIRC the order of the keys is NOT defined, except that integer keys
> appear in increasing order. If this is right, your approach relies on
> implementation details that may change. With that warning....
>

The elements of the array do have an order -- and it isn't necessarily
the order of the keys, even when using integers. It's the order in
which they were added to the array. If they had no order then
functions like sort() would be pretty useless. Try this:

$a = array();

$a[1] = 'foo';
$a[0] = 'bar';
$a[2] = 'baz';

print_r($a);

You'll get the same result if you replace the print_r() with a
foreach.

[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

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