|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[1999-07-27 12:18 UTC] andrey at cvs dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Jun 10 20:00:01 2026 UTC |
run the following script on php3 and php4: <? function reverse_key_sort($a, $b) { if ($a == $b) return 0; return ($a > $b) ? -1 : 1; } $a = array(1 => 'orange', 2 => 'apple', 3 => 'bananna'); uksort($a, reverse_key_sort); reset($a); while ( list($key, $val) = each($a) ) { echo "KEY=$key VAL=$val<BR>"; } ?> The output looks like this for php3: KEY=3 VAL=bananna KEY=2 VAL=apple KEY=1 VAL=orange And like this for php4: KEY=1 VAL=orange KEY=2 VAL=apple KEY=3 VAL=bananna Also, the only reason that I have use the uksort function is because php3 lacks a rksort() function (even though it has a ksort() function) It seems like it shouldnt be to difficult to add the rksort() function? (Cut and paste the ksort() and reverse the sorting?) Thanks, Brian Bray