二维数组以某一列的大小正向排序
Laiyong Wang Lv5
二维数组以某一列的大小正向排序
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//代码示例
$factoryWave = [
[
'qwe' => 3,
'weight_kg' => 3,
],
[
'qwe' => 4,
'weight_kg' => 4
],
[
'qwe' => 1,
'weight_kg' => 1,
],
[
'qwe' => 2,
'weight_kg' => 2,
],
];

$weightKgArr = array_column($factoryWave, 'weight_kg');
array_multisort($weightKgArr, $factoryWave);
var_dump($weightKgArr);
var_dump($factoryWave);
 Comments