PHP 里面的数组按照某个时间字段排序

https://blog.csdn.net/u012015434/article/details/48153847


$store_list = Array

(

    [0] => Array

        (

            [name] => asdf

            [head] => /upload/thumbs/20150814220142_27630.jpg

            [img] =>

            [content] => asdfasdfasdf

            [datetime] => 2015-10-11 09:55:08

            [flag] => false

        )

    [1] => Array

        (

            [name] => 基本原则顶替

            [head] =>

            [img] =>

            [content] => 基本原则顶替

            [datetime] => 2015-09-01 10:41:08

            [flag] => true

        )

    [2] => Array

        (

            [name] => ad

            [head] => /upload/thumbs/20150814220142_27630.jpg

            [img] =>

            [content] => asdfasdf

            [datetime] => 2015-09-01 09:51:08

            [flag] => false

        )

)

foreach($sort_list as $key=>$v){

$sort_list[$key]['datetime'] = date("YmdHis",strtotime($v['datetime']));

}

$datetime = array();

foreach ($sort_list as $user) {

$datetime[] = $user['datetime'];

}

array_multisort($datetime,SORT_DESC,$sort_list);

print_r()

你可能感兴趣的:(PHP 里面的数组按照某个时间字段排序)