PHP二维数组排序
super
2021-05-31 15:54
2617
代码示例:
$array = [
[
'name' => 'super1',
'age' => 12
],
[
'name' => 'super2',
'age' => 10
],
[
'name' => 'super3',
'age' => 14
]
];
foreach ($array as $key => $row) {
$distance[$key] = $row['age'];
}
array_multisort($distance, SORT_DESC, $array); // SORT_ASC 按照上升顺序排序, SORT_DESC 按照下降顺序排序。
print_r($array);
运行结果
0 条讨论