订购多维数组

时间:2012-04-24 20:57:31

标签: php arrays multidimensional-array

我希望通过数组的“timestamp”部分从最低到最高(ASC)对以下数组进行排序。

Array
(
[188] => Array
    (
        [date] => 28-04-2012
        [timestamp] => 1335571200
        [opposition] => Rayleigh 1st XI
        [teaperson] => 
    )

[182] => Array
    (
        [date] => 08-03-2012
        [timestamp] => 1331164800
        [opposition] => Galleywood 1st XI
        [teaperson] => 33
    )

[180] => Array
    (
        [date] => 07-07-2012
        [timestamp] => 1341619200
        [opposition] => High Roding 1st XI
        [teaperson] => 45
    )

)

我已经看过array_multisort函数,但不确定如何正确使用它。

干杯

1 个答案:

答案 0 :(得分:1)

使用usort

usort($arr,function($a,$b) {return $a['timestamp']-$b['timestamp'];})