Sorting a multidimensional array?

后端 未结 2 1893
借酒劲吻你
借酒劲吻你 2021-01-06 21:57

I have an array that looks like this:

Array ( [0] => Array ( [filters] => Array ( [filter_1] => 1 
                                            [filt         


        
2条回答
  •  再見小時候
    2021-01-06 22:00

    You'll need to use the uasort function. Try something like this:

    function cmp($a, $b) {
        if ($a["count"] == $b["count"]) {
            return 0;
        }
        return ($a["count"] > $b["count"]) ? -1 : 1;
    }
    
    uasort($array, 'cmp');
    

提交回复
热议问题