#18629 [Opn->Bgs]: Undocumented behavior of arrays
| From: | jmcastagnetto@php.net | Date: | Mon, 29 Jul 2002 20:55:41 +0000 |
| Subject: | #18629 [Opn->Bgs]: Undocumented behavior of arrays | ||
| References: | 1 | Groups: | php.bugs php.doc |
| Request: | Send a blank email to php-bugs+get-15521@lists.php.net to get a copy of this message | ||
ID: 18629
Updated by: jmcastagnetto@php.net
Reported By: paul@honeylocust.com
-Status: Open
+Status: Bogus
Bug Type: Documentation problem
Operating System: Linux
PHP Version: 4.2.2
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Arrays in PHP are the equivalent to hashes in other languages, so the
order of the elements is not assured. The foreach construct will
retrieved the data from the hash similarly, so in the general case you
should not rely on the order being the original order.
Not sure it should be documented that for PHP compiled on under some
OSes and compiler combinations results in the element order being kept.
After all the reason for using associative arrays is to be able to
access elements by "name".
Previous Comments:
------------------------------------------------------------------------
[2002-07-29 14:50:38] paul@honeylocust.com
If you iterate an associative array with foreach(), it seems like it
plays elements back in the order in which they were added. This
behavior is useful, but seems to be undocumented. I'd like to see
this documented, because otherwise I'm afraid this behavior will
change in future versions of PHP.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=18629&edit=1