時間順にソートされた配列

WBOY
WBOYオリジナル
2016-06-20 12:43:02976ブラウズ

以下のような配列があり、最新の6個のデータを時間順に取得したいとします。 コードは次のとおりです。 🎜>

Array(    [0] => Array        (            [id] => 81            [title] => 撒大声地            [uid] => 166            [created_time] => 2015-11-25 17:15:27            [1] => 1        )    [1] => Array        (            [id] => 80            [title] => 唐门提问问题标题一            [uid] => 166            [created_time] => 2015-11-20 14:49:57            [1] => 1        )    [2] => Array        (            [id] => 22            [title] => test            [uid] => 126            [created_time] => 2015-12-10 14:49:57            [2] => 2        )       [3] => Array        (            [id] => 78            [title] => 123            [uid] => 122            [created_time] => 2015-11-16 15:52:19            [1] => 1        )    [4] => Array        (            [id] => 77            [title] => dsfasd            [uid] => 156            [created_time] => 2015-11-09 11:04:24            [1] => 1        )    [5] => Array        (            [id] => 76            [title] => CE            [uid] => 156            [created_time] => 2015-11-04 16:44:34            [1] => 1        ) [6] => Array        (            [id] => 79            [title] => 测试            [uid] => 156            [created_time] => 2015-11-18 14:28:44            [1] => 1        )    [7] => Array        (            [id] => 21            [title] => 没删除—1            [uid] => 126            [created_time] => 2015-07-02 13:50:44            [2] => 2        )    [8] => Array        (            [id] => 20            [title] => 没删除—1            [uid] => 126            [created_time] => 2015-07-02 13:50:44            [2] => 2        )    [9] => Array        (            [id] => 19            [title] => 没删除—1            [uid] => 126            [created_time] => 2015-07-02 13:50:44            [2] => 2        )    [10] => Array        (            [id] => 18            [title] => 没删除—1            [uid] => 126            [created_time] => 2015-07-02 13:50:44            [2] => 2        )    [11] => Array        (            [id] => 17            [title] => 1人撒Yui日体育规范地方发货方撒地方            [uid] => 3            [created_time] => 2015-07-02 13:50:44            [2] => 2        ))

ディスカッションへの返信 (解決策)

foreach($arr as $v) $r[] = $v['created_time ']; array_multisort($r, SORT_DESC , $arr); $ar = array_slice($arr, 0, 6);
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。