how to sort a multidemensional array by an inner key

后端 未结 6 1049
你的背包
你的背包 2020-12-02 02:34

i have this enormous array that i am pulling from an API for BattleField Bad Company 2, and the soldier stats can be pulled as a multi dimensional array with an inner array

6条回答
  •  失恋的感觉
    2020-12-02 03:07

    To order descending an array, I used

    function sorterdesc($one, $two) {
        return ($two['cont'] - $one['cont']);
    }
    

    For ascending :

    function sorterasc($one, $two) {
        return ($one['cont'] - $two['cont']);
    }
    

    Like this it works fine with numeric values

提交回复
热议问题