note 28526 deleted from language.types.array by tomsommer
| From: | tomsommer@php.net | Date: | Sat, 03 Jul 2004 13:24:41 +0000 |
| Subject: | note 28526 deleted from language.types.array by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72424@lists.php.net to get a copy of this message | ||
Note Submitter:
----
/* It helps to think of numeric indices
* in the same way as string indices...
* That is, the order in which they are
* added in determines the internal order,
* not the index. For example:
*/
// for string indices:
$foo["c"] = "c";
$foo["b"] = "b";
$foo["a"] = "a";
print_r($foo);
/* prints:
Array
(
[c] => c
[b] => b
[a] => a
)
*/
// likewise, for numerical indices:
$bar[2] = 2;
$bar[1] = 1;
$bar[0] = 0;
print_r($bar);
/* prints:
Array
(
[2] => 2
[1] => 1
[0] => 0
)
*/
/* If you are unsure of what the *internal* order
* of your array is, either use a for() loop, or
* use the array sorting functions.
*/