note 79690 added to ref.array
| From: | kevwilliamsatgeemaildotcom at osu1 dot php dot net | Date: | Sat, 08 Dec 2007 11:32:04 +0000 |
| Subject: | note 79690 added to ref.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132951@lists.php.net to get a copy of this message | ||
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?
----
Server IP: 203.202.10.60
Probable Submitter: 58.6.117.170
----
Manual Page -- http://www.php.net/manual/en/ref.array.php
Edit -- https://master.php.net/note/edit/79690
Del: integrated -- https://master.php.net/note/delete/79690/integrated
Del: useless -- https://master.php.net/note/delete/79690/useless
Del: bad code -- https://master.php.net/note/delete/79690/bad+code
Del: spam -- https://master.php.net/note/delete/79690/spam
Del: non-english -- https://master.php.net/note/delete/79690/non-english
Del: in docs -- https://master.php.net/note/delete/79690/in+docs
Del: other reasons-- https://master.php.net/note/delete/79690
Reject -- https://master.php.net/note/reject/79690
Search -- https://master.php.net/manage/user-notes.php