我正在尝试按数组键对多维数组进行排序。我查看了 array_multisort, array_multisort($result['EVENT'], SORT_NUMERIC, SORT_DESC); 但它仅对事件数组值进行排序我需要按事件值(DESC 顺序)排序,我的数组如下所示: Array ( [POLICY] => Array ( [0] => 278395 [1] => 278395 ) [EVENT] => Array ( [0] => 1 [1] => 2 ) [EVENT_TYPE] => Array ( [0] => INITIAL POLICY [1] => POLICY CORRECTION ) [DATE] => Array ( [0] => 03-JAN-20 [1] => 18-JUN-20 ))预期输出: Array ( [POLICY] => Array ( [0] => 278395 [1] => 278395 ) [EVENT] => Array ( [0] => 2 [1] => 1 ) [EVENT_TYPE] => Array ( [0] => POLICY CORRECTION [1] => INITIAL POLICY ) [DATE] => Array ( [0] => 18-JUN-20 [1] => 03-JAN-20 ))
1 回答
吃鸡游戏
TA贡献1829条经验 获得超7个赞
您需要将其他子数组作为参数添加到array_multisort,以便它们与 EVENT 列一起重新排序:
array_multisort($result["EVENT"], SORT_NUMERIC, SORT_DESC,
$result["POLICY"],
$result["EVENT_TYPE"],
$result["DATE"]);
- 1 回答
- 0 关注
- 81 浏览
添加回答
举报
0/150
提交
取消