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

From: Date: Thu, 20 Jun 2002 08:55:01 +0000
Subject: Bug #17869 Updated: Array sort order broken with more than 256 entries in an associative array?
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-11526@lists.php.net to get a copy of this message
ID: 17869 Updated by: adamek@webtrio.de Reported By: adamek@webtrio.de Status: Open Bug Type: Arrays related Operating System: Linux 2.4.16 PHP Version: 4.2.1 New Comment: Mistype in my bug report ;-) The line while ($q = get_object($result)) must be while ($q = mysql_fetch_object($result)) of course ..... forgot to replace my mysql query wrapper code with real mysql_ function .... Of course bug is still present - has nothing to do with mysql ... Previous Comments: ------------------------------------------------------------------------ [2002-06-20 04:50:02] adamek@webtrio.de 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 this bug report at http://bugs.php.net/?id=17869&edit=1

« previous php.bugs (#11526) next »