如何按日期升序排列此数组


How arrange this array in ascending order by date?

这是我的数组

[comment] => Array
        (
            [0] => Array
                (
                    [mem_id] => 51
                    [comment] => nice...
                    [profilenam] => xyz
                    [photo_thumb] => photos/81951b37ad01c4aa65662956f178214eth.jpeg
                    [date] => 1307975661
                )
            [1] => Array
                (
                    [mem_id] => 329
                    [comment] => nice...
                    [profilenam] => abc
                    [photo_thumb] => photos/f841eab12f5a24ce12b984904760c05fth.jpeg
                    [date] => 1308043486
                )
        )

实际上,我想按日期升序排列,我使用了asort(),但无法使用

usort($ar['comment'], function($v1, $v2) {
    return $v1['date'] - $v2['date'];
});

在php<5.3,使用create_function而不是匿名函数表示法。

您正在对一个又一个数组进行排序,在这种情况下,带有内置比较函数的内置排序函数都无法工作。请改用usort或uaort。

我还没有测试过,但像这样:

uasort($comment, function ($a, $b) { return $a['date'] - $b['date']; } );