PHP3 Manual | ||
---|---|---|
Prev | Next |
usort -- Sort an array using a user-define comparison function
This function will sort an array using a user-supplied comparison function. If the array you wish to sort needs to be sorted by some non-trivial criteria, you should use this function.
Example 1. usort() example function cmp($a,$b) { if($a==$b) return 0; return ($a>$b) ? -1:1; } $a = array(3,2,5,6,1); usort($a,cmp); while(list($key,$value) = each($a)) { echo "$key: $value\n"; } |
Prev | Home | Next |
sort | Up | BC (Arbitrary Precision) Functions |