在密钥PHP的值之后对数组进行多维排序

时间:2015-09-23 08:28:03

标签: php arrays sorting multidimensional-array

我有一个数组,这个,我可以按键sum

的值来排序
Array
(
[anexus] => Array
    (
        [nr000000] => Array
            (
                [January2015] => Array
                    (
                        [nTurn] => 0.0000
                        [nCalls] => 0
                        [nMin] => 0
                        [c] =>l
                    )

                [sum] => 0
                [February2015] => Array
                    (
                        [nTurn] => 0.0000
                        [nCalls] => 0
                        [nMin] => 0
                        [c] => ch
                    )

                [March2015] => Array
                    (
                        [nTurn] => 0.0000
                        [nCalls] => 0
                        [nMin] => 0
                        [c] => 
                    )


            )

        [nrh00789] => Array
            (
                [January2015] => Array
                    (
                        [nTurn] => 0.0000
                        [nCalls] => 0
                        [nMin] => 0
                        [c] => 
                    )

                [sum] => 0
                [February2015] => Array
                    (
                        [nTurn] => 0.0000
                        [nCalls] => 0
                        [nMin] => 0
                        [c] => ch
                    )

                [March2015] => Array
                    (
                        [nTurn] => 0.0000
                        [nCalls] => 0
                        [nMin] => 0
                        [c] => ch
                    )




            )

    )

[deluxe] => Array
    (
        [nr00078] => Array
            (
                [January2015] => Array
                    (
                        [nTurn] => 0.0000
                        [nCalls] => 0
                        [nMin] => 0
                        [c] => at
                    )

                [sum] => 21
                [February2015] => Array
                    (
                        [nTurn] => 0.0000
                        [nCalls] => 0
                        [nMin] => 0
                        [c] => at
                    )

                [March2015] => Array
                    (
                        [nTurn] => 0.0000
                        [nCalls] => 0
                        [nMin] => 0
                        [c] =>p
                    )



            )

        [nr000800] => Array
            (
                [January2015] => Array
                    (
                        [nTurn] => 0.0000
                        [nCalls] => 0
                        [nMin] => 0
                        [c] => de
                    )

                [sum] => 71
                [February2015] => Array
                    (
                        [nTurn] => 0.0000
                        [nCalls] => 0
                        [nMin] => 0
                        [c] => de
                    )

                [March2015] => Array
                    (
                        [nTurn] => 0.0000
                        [nCalls] => 0
                        [nMin] => 0
                        [c] => de
                    )





            )

这是数组的一部分,我要在键sum

之后排序

1 个答案:

答案 0 :(得分:0)

只需使用 array_shift(),查看http://php.net并使用您想要的任何功能进行排序,然后您就可以添加" sum"使用 array_unshift()返回,查看this