数组根据某个字段倒序
$array=array( 0=>array( 'id'=>1, 'num1'=>-1, 'num2'=>100 ), 1=>array( 'id'=>2, 'num1'=>4, 'num2'=>50 ), 2=>array( 'id'=>3, 'num1'=>900, 'num2'=>800 ), 3=>array( 'id'=>4, 'num1'=>-16, 'num2'=>-15 ) ); //主要 foreach ($array as $key=>$value){ $cha[$key] = $value['num2']-$value['num1']; } array_multisort($cha,SORT_STRING,SORT_DESC,$array); // echo ' '; print_r($array); echo '';