|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-06-20 04:50 UTC] adamek at webtrio dot 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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 23 20:00:01 2025 UTC |
The bug still stays when replacing some lines: Replace the line $userlist[$q->UID."-".$q->Server] = $q->Username." (".$q->Server.")"; by the lines: $arraykey = $q->UID.".".$q->Server; $arrayvalue = $q->Username." (".$q->Server.")"; $userlist[$arraykey] = $arrayvalue; (key and value prepared)