ID: 20982 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Open +Status: Closed Bug Type: Arrays related Operating System: NetBSD/Alpha (64bit) - 1.6 PHP Version: 4.2.2 New Comment:
This bug has been fixed in CVS. In case this was a PHP problem, snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. In case this was a documentation problem, the fix will show up soon at http://www.php.net/manual/. In case this was a PHP.net website problem, the change will show up on the PHP.net site and on the mirror sites in short time. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2002-12-13 00:37:26] [EMAIL PROTECTED] I also tried other various sort functions and they all failed to sort: # cat sort.php <?php // sort() demo echo "\n"; $fruits = array ("lemon", "orange", "banana", "apple"); sort ($fruits); reset ($fruits); while (list ($key, $val) = each ($fruits)) { echo "fruits[".$key."] = ".$val."\n"; } // asort() demo echo "\n"; $fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); asort ($fruits); reset ($fruits); while (list ($key, $val) = each ($fruits)) { echo "$key = $val\n"; } // ksort() demo echo "\n"; $fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); ksort ($fruits); reset ($fruits); while (list ($key, $val) = each ($fruits)) { echo "$key = $val\n"; } // usort() demo echo "\n"; $fruits = array(); function cmp ($a, $b) { return strcmp($a["fruit"], $b["fruit"]); } $fruits[0]["fruit"] = "lemons"; $fruits[1]["fruit"] = "apples"; $fruits[2]["fruit"] = "grapes"; usort($fruits, "cmp"); while (list ($key, $value) = each ($fruits)) { echo "\$fruits[$key]: " . $value["fruit"] . "\n"; } ?> # php -q sort.php fruits[0] = lemon fruits[1] = orange fruits[2] = banana fruits[3] = apple d = lemon a = orange b = banana c = apple d = lemon a = orange b = banana c = apple $fruits[0]: lemons $fruits[1]: apples $fruits[2]: grapes # ------------------------------------------------------------------------ [2002-12-13 00:09:11] [EMAIL PROTECTED] # cat sort.php <?php $fruits = array ("lemon", "orange", "banana", "apple"); sort ($fruits); reset ($fruits); while (list ($key, $val) = each ($fruits)) { echo "fruits[".$key."] = ".$val."\n"; } ?> # php -v 4.2.2 # php -q sort.php fruits[0] = lemon fruits[1] = orange fruits[2] = banana fruits[3] = apple # ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=20982&edit=1