Sorting array by count of subarray

前端 未结 3 1928
情歌与酒
情歌与酒 2021-01-14 01:06

I have an array looking like this:

Array(
   [\'some_first_category\'] => Array(
            [\'some_first_name\'] => Array(
                                   


        
3条回答
  •  醉梦人生
    2021-01-14 01:50

    You should use usort function. Refer here.

    function sort_sub($a,$b)
    {
    $res= count($b)-count($a);
    return $res;
    }
    
    usort($array_name,'sort_sub')
    

提交回复
热议问题