PHP sort multidimensional array with primary & secondary keys

后端 未结 4 549
无人共我
无人共我 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:21

    array_multisort() should give you the functionality that you need... use Example #3 from the PHP documentation as the basis for your sort, although you'll need to convert those date strings to a datestamp value before executing the sort.

    If this data has come from a database query though, it's far easier to sort it within the sql query used to retrieve the information.

提交回复
热议问题