Sort Multi Array in PHP

后端 未结 9 1909
清酒与你
清酒与你 2021-01-23 07:10

Does anybody have an idea how can I sort this array by key (date) in PHP?

Array
(   
    [2011-02-16] => Array
        (
            [date] => 2011-02-16
          


        
9条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-23 08:04

    This should help you brush up on the basics of array sorting in PHP

    http://www.the-art-of-web.com/php/sortarray/

    Something like this would sort your problem however:

    usort($array, "cmp");
    
    function cmp($a, $b){ 
        return strcmp($b['date'], $a['date']); 
    

提交回复
热议问题