doufei7516 2011-06-14 15:36
浏览 48

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

this is my array

[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
                )

        )

actually i wanted to arrange in ascending order by date , i used asort() but didn't work

  • 写回答

3条回答 默认 最新

  • douya2007 2011-06-14 15:40
    关注
    usort($ar['comment'], function($v1, $v2) {
        return $v1['date'] - $v2['date'];
    });
    

    In php<5.3, use create_function instead of the anonymous function notation.

    评论

报告相同问题?

悬赏问题

  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?