从小到大,从大到小,PHP 数组排序 - 简书

5177 人参与 | 时间:2022年09月26日 18:59:01

$arr = array( '0' => array( 'num1' => 3, 'num2' => 27 ), '1' => array( 'num1' => 5, 'num2' => 50 ), '2' => array( 'num1' => 4, 'num2' => 44 ), '3' => array( 'num1' => 3, 'num2' => 78 ) ); foreach ($arr as $key => $row) { $num1[$key] = $row['num1']; $num2[$key] = $row['num2']; } array_multisort($num1, SORT_ASC, $num2, SORT_DESC, $arr); print_r($arr);

.