note 14104 modified in function.usort by danbrown

From: Date: Sun, 23 Jan 2011 16:32:56 +0000
Subject: note 14104 modified in function.usort by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-176087@lists.php.net to get a copy of this message
For sort multi-array by specific index <?php 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"); ?> --was-- 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://php.net/manual/en/function.usort.php

« previous php.notes (#176087) next »