PHP二维数组按某个键值排序

$data=Array
(
    [0] => Array
        (
            [id] => 2
            [user_id] => 14       
            [amount] => 90000.00
            [status] => 2
            [remarks] =>
            [create_time] => 2018-06-26 17:29:49
        )

    [1] => Array
        (
            [id] => 1
            [user_id] => 14
            [amount] => 100000.0       
            [status] => 2
            [remarks] => wrferqwqwe
            [create_time] => 2018-06-26 17:15:15
        )

    [2] => Array
        (
            [id] => 38
            [transfer_sn] => 180622094323403
            [type] => 0
            [out_user_id] => 13
            [in_user_id] => 14
            [amount] => 12.00
            [create_time] => 2018-06-22 09:43:23
        )
)

如要按 create_time排序:

array_multisort(array_column($data,'create_time'),SORT_DESC,$data)

array_multisort(数组(一维数组),排序方式(SOTR_ASC,SOTR_DESC),其他数组(可以是二维的))

 

转载于:https://www.cnblogs.com/goufugui/p/9232551.html

你可能感兴趣的:(php)