PHP sort multidimensional array with primary & secondary keys

后端 未结 4 546
无人共我
无人共我 2021-01-13 11:17

How do you sort a multidimensional array by primary and secondary key? For example, assuming the following array:

$result = array();

$result[0][\"prio\"] =          


        
4条回答
  •  攒了一身酷
    2021-01-13 12:06

    PHP doesn't have a built-in function to do complex sorting like this, so you'll need to do a usort(), which allows you to sort items using a function that specifies your own criteria.

    The example given on the PHP manual page is almost an exact match for what you want to achieve.

提交回复
热议问题