-1

したがって、1レベルの深さの連想配列があります(以下の抜粋)が、多くのエントリがあります

[0] => Array
            (
                [Electronic] => 1
                [Scope] => Intruder Alarm Systems                                                                              
                [Issued Date] => 2013-07-23 01:03:41
                [Customer Name] => qqqq
                [Certificate Number] => 1291087
            )

        [1] => Array
            (
                [Electronic] => 1
                [Scope] => CCTV Systems                                                                                        
                [Issued Date] => 2013-07-23 01:02:01
                [Customer Name] => qqqqq
                [Certificate Number] => 1291085
            )

        [2] => Array
            (
                [Electronic] => 1
                [Scope] => CCTV Systems                                                                                        
                [Issued Date] => 2013-07-17 07:15:06
                [Customer Name] => Accent Foundation Ltd
                [Certificate Number] => 1290822
            )

この配列をループして並べ替え、最新のものが最初になるようにする方法が必要です。基本的には、DBから選択して「ORDER BY "Issued Date" DESC」を使用したかのように

私はこれを行う方法を本当に考えることはできません。

4

2 に答える 2

1

usort独自のカスタム関数を使用して並べ替えることができます。

usort($array, function ($a, $b) {
     $atime = strtotime($a['Issue Date']);
     $btime = strtotime($b['Issue Date']);
     return $atime - $btime;
});
于 2013-07-25T13:16:36.293 に答える