Bug #17869: Array sort order broken with more than 256 entries in an associative array?

From: Date: Thu, 20 Jun 2002 08:50:03 +0000
Subject: Bug #17869: Array sort order broken with more than 256 entries in an associative array?
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-11524@lists.php.net to get a copy of this message
From: adamek@webtrio.de Operating system: Linux 2.4.16 PHP version: 4.2.1 PHP Bug Type: Arrays related Bug description: Array sort order broken with more than 256 entries in an associative array? To reproduce the problem do the following: 1) Read a mysql database table with user names and a double index (UID, server - both numeric) having about 280 entries: SELECT UID,Server,Username FROM Users ORDER BY UID,Server 2) Preparing the array: $userlist = array(); 3) Filling the array: $result = mysql_query("SELECT UID,Server,Username FROM Users ORDER BY UID,Server"); if ($result) { while ($q = get_object($result)) { $userlist[$q->UID."-".$q->Server] = $q->Username." (".$q->Server.")"; // Debug output just to see that filling happens in the right alphabetical order of user names echo $userlist[$q->UID."-".$q->Server]."\n"; } } 4) Reading the array: foreach ($userlist as $key => $value) { echo $key." = ".$value."\n"; } you suddenly notice that the array entry no. 256 and 257 appear at the wrong place (at position count($userlist)-256) - the internal sort order of the array has changed! I also tried this with array index names in the form: [$q->UID.":".$q->Server] and [$q->UID.".".$q->Server] Both with the same wrong result ... arrays read out don't have the same order as they were filled any more if more than 256 entries are present. -- Edit bug report at http://bugs.php.net/?id=17869&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=17869&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=17869&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=17869&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=17869&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=17869&r=support Expected behavior: http://bugs.php.net/fix.php?id=17869&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=17869&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=17869&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=17869&r=globals

« previous php.bugs (#11524) next »