Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php中对多维数组排序?_Php_Arrays_Sorting - Fatal编程技术网

如何在php中对多维数组排序?

如何在php中对多维数组排序?,php,arrays,sorting,Php,Arrays,Sorting,我必须在date中键入PHP对给定数组进行排序。我尝试过使用array_multisort进行排序,但无法对其进行排序。哪个更适合usort或array\U multisort Array ( [165953] => Array ( [0] => Array ( [wallet_transaction_id] => 165953

我必须在date中键入PHP对给定数组进行排序。我尝试过使用array_multisort进行排序,但无法对其进行排序。哪个更适合usort或array\U multisort

Array
(
    [165953] => Array
        (
            [0] => Array
                (
                    [wallet_transaction_id] => 165953
                    [wallet_currency_id] => 2
                    [description] => updating SC Dollars by 100.00 from PSM product transaction.
                    [amount] => 100.00
                    [date] => 2013-11-13 08:08:05
                )

            [1] => Array
                (
                    [wallet_transaction_id] => 165953
                    [wallet_currency_id] => 3
                    [description] => updating Spy Points by 50.00 from PSM product transaction.
                    [amount] => 50.00
                    [date] => 2013-11-13 06:08:05
                )

        )

    [165952] => Array
        (
            [0] => Array
                (
                    [wallet_transaction_id] => 165952
                    [wallet_currency_id] => 2
                    [description] => updating SC Dollars by 100.00 from PSM product transaction.
                    [amount] => 100.00
                    [date] => 2013-11-13 05:02:11
                )

            [1] => Array
                (
                    [wallet_transaction_id] => 165952
                    [wallet_currency_id] => 3
                    [description] => updating Spy Points by 50.00 from PSM product transaction.
                    [amount] => 50.00
                    [date] => 2013-11-13 08:02:11
                )

        )
)

您应该查看usort函数。让您定义自己的比较函数


您希望结果是什么样的?我假设对于数组中的每个元素(
165953
165952
),您希望对该数组进行排序。。。是吗?它是复制品。第一个答案在内存和速度方面都最有效。