ID: 18629 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Bogus Bug Type: Documentation problem Operating System: Linux PHP Version: 4.2.2 New Comment:
Well, actually, PHP arrays are always ordered arrays. They are hashes in the sense that the index can be anything. Perhaps a better description is that they are ordered associative arrays. So yes, you can rely on the order remaining constant and this will not change. Previous Comments: ------------------------------------------------------------------------ [2002-07-29 16:55:40] [EMAIL PROTECTED] 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\". ------------------------------------------------------------------------ [2002-07-29 14:50:38] [EMAIL PROTECTED] 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 -- PHP Documentation Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php