使用array_multisort按多列/键对数组进行排序

时间:2018-01-15 11:05:52

标签: php array-multisort

如何对下面的数组元素进行排序?

dRows或cRows中的每个数组项都需要使用array_multisort按日期(最早的第一个),acc(asc),am(asc)进行排序?

我尝试在foreach中使用array_multisort而没有foreach但是它没有做任何事情并且它不会对它进行排序

[1000] => Array
        (
            [dRows] => Array
                (
                    [0] => Array
                        (
                            [acc] => 100
                            [am] => 100.00
                            [date] => 2016-04-27
                        )

                    [1] => Array
                        (
                            [acc] => 100
                            [amount] => 130.80
                            [date] => 2016-04-27
                        )

                    [2] => Array
                        (
                            [acc] => 101
                            [amount] => 30.80
                            [date] => 2016-04-26
                        )

                )

            [cRows] => Array
                (
                    [0] => Array
                        (
                            [acc] => 200
                            [amount] => 100.00
                            [date] => 2016-06-25
                        )

                    [1] => Array
                        (
                            [acc] => 201
                            [amount] => 130.80
                            [date] => 2016-06-25
                        )

                    [2] => Array
                        (
                            [acc] => 200
                            [amount] => 30.80
                            [date] => 2016-04-27
                        )

                    [3] => Array
                        (
                            [acc] => 200
                            [amount] => 30.80
                            [date] => 2016-04-26
                        )

                )
        )

0 个答案:

没有答案