note 79690 deleted from ref.array by nlopess

From: Date: Sat, 08 Dec 2007 11:39:56 +0000
Subject: note 79690 deleted from ref.array by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-132952@lists.php.net to get a copy of this message
Note Submitter: kevwilliams at gee mail dot com ---- Important note, when inserting elements into an array they stay in the order they are inserted even if you use numerical keys. Example: $a = array(4=>'Four',1=>'One',2=>'Two'); print_r($a); Outputs: Array ( [4] => Four [1] => One [2] => Two ) To get them in correct order you must use ksort(). I'm not sure why this is desired functionality, if someone could explain I would love to know the reason. If you use numerical indexes, is the array treated as an associative array?

« previous php.notes (#132952) next »