note 38544 added to function.uksort

From: Date: Fri, 26 Dec 2003 12:32:28 +0000
Subject: note 38544 added to function.uksort
Groups: php.notes 
Request: Send a blank email to php-notes+get-62500@lists.php.net to get a copy of this message
Can someone please help me out here? I need to sort this Array by the number from big to small. This script I wrote does part of the job but I don't know how to display back the Value of the items??? Here is the script: <? $array = Array ( "[G-3010F-2AV]" => "1", "[G-2110V-8]" => "4", "[MTD-1044A-1AVDF]" => "2", "[F-201W-1AEF]" => "1", "[PANASONIC SL-SX420]" => "16", "[MZ-N510CK SONY]" => "38", "[G-2110-1V]" => "1", "[W-59]" => "1", "[G-2600-2VMER]" => "2", "[AW-80D-2A]" => "1" ); $a = array_count_values($array); //print_r($a); function cmp($a, $b) { if ($a == $b) { return 0; } return ($a > $b) ? -1 : 1; } /* ================================================= */ uksort($a, "cmp"); while (list($key, $value) = each($a)) { echo "$key: $value\n"; } ?> --Tal ---- Manual Page -- http://www.php.net/manual/en/function.uksort.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38544 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38544&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38544&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#62500) next »