我正在嘗試按數(shù)組鍵對多維數(shù)組進(jìn)行排序。我查看了 array_multisort, array_multisort($result['EVENT'], SORT_NUMERIC, SORT_DESC); 但它僅對事件數(shù)組值進(jìn)行排序我需要按事件值(DESC 順序)排序,我的數(shù)組如下所示: 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 ))預(yù)期輸出: 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貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超7個贊
您需要將其他子數(shù)組作為參數(shù)添加到array_multisort,以便它們與 EVENT 列一起重新排序:
array_multisort($result["EVENT"], SORT_NUMERIC, SORT_DESC,
$result["POLICY"],
$result["EVENT_TYPE"],
$result["DATE"]);
- 1 回答
- 0 關(guān)注
- 120 瀏覽
添加回答
舉報
0/150
提交
取消