note 14104 added to function.usort.php
| From: | franky at iname dot com | Date: | Tue, 17 Jul 2001 19:08:46 +0000 |
| Subject: | note 14104 added to function.usort.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-15496@lists.php.net to get a copy of this message | ||
For sort multi-array by specific index
function cmp ($a, $b)
{
global $w_o;
if ($a[$w_o] == $b[$w_o]) return 0;
return ($a[$w_o] < $b[$w_o]) ? -1 : 1;
}
# the index is the second element of
# each row
$w_o =1;
usort($my_arry_info,"cmp");
http://www.php.net/manual/en/function.usort.php