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]
|