需求 数组排序 id降序,value降序,nii升序
$arr = array(
1=>array(
'id' => 5,
'value' => '2018-12-20 12:09:30',
'nii' => '6',
),
2=>array(
'id' => 5,
'value' => '2018-12-20 12:09:30',
'nii' => '2',
),
3=>array(
'id' => 5,
'value' => '2018-12-21 12:09:30',
'nii' => '5',
),
4=>array(
'id' => 8,
'value' => '2018-12-21 12:09:30',
'nii' => '5',
),
5=>array(
'id' => 6,
'value' => '2018-12-22 12:09:30',
'nii' => '5',
)
);
print_r($arr);
$id = array_column($arr,'id');
$value = array_column($arr,'value');
$nii = array_column($arr,'nii');
//print_r([$id,$value,$nii]);exit;
array_multisort($id,SORT_DESC,$value,SORT_DESC,$nii,SORT_ASC,$arr);
print_r($arr); exit;
打印情况,解决!
Array
(
[1] => Array
(
[id] => 5
[value] => 2018-12-20 12:09:30
[nii] => 6
)
[2] => Array
(
[id] => 5
[value] => 2018-12-20 12:09:30
[nii] => 2
)
[3] => Array
(
[id] => 5
[value] => 2018-12-21 12:09:30
[nii] => 5
)
[4] => Array
(
[id] => 8
[value] => 2018-12-21 12:09:30
[nii] => 5
)
[5] => Array
(
[id] => 6
[value] => 2018-12-22 12:09:30
[nii] => 5
)
)
Array
(
[0] => Array
(
[id] => 8
[value] => 2018-12-21 12:09:30
[nii] => 5
)
[1] => Array
(
[id] => 6
[value] => 2018-12-22 12:09:30
[nii] => 5
)
[2] => Array
(
[id] => 5
[value] => 2018-12-21 12:09:30
[nii] => 5
)
[3] => Array
(
[id] => 5
[value] => 2018-12-20 12:09:30
[nii] => 2
)
[4] => Array
(
[id] => 5
[value] => 2018-12-20 12:09:30
[nii] => 6
)
)