Reply to Numerically Indexed Arrays...Out of order???

Your name:

Reply:


Posted by kaydubbleu on 12/08/07 11:36

I have found that when inserting elements into an array they stay in
the same order they are inserted, even when using numerical keys.

Example:
$a = array(4=>'Four',1=>'One',5=>'Five',2=>'Two',3=>'Three');
print_r($a);

Ouptuts:
Array
(
[4] => Four
[1] => One
[5] => Five
[2] => Two
[3] => Three
)

The only way to get them into proper order is to use ksort(). I am not
sure why this is desired functionality. If someone could please
explain I would love to know..

When inserting numerically indexed elements into an array is it
treated as an associative array?

Thanks ahead of time.

[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

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