This article mainly and everyone to share the PHP array time sequencing detailed, hope to help everyone.
Idea: 1.2018-03-20 16:19:00 format.
2.php function Array_multisort (); sort
$ arr = Array (' A ' =>array (' uid ' =>12, ' name ' = ' zhangsan1 ', ' ctime ' = ' = ' 2018-03-20 11:28:00 '), ' B ' =>array (' uid ' =>13, ' name ' = ' zhangsan2 ', ' ctime ' = ' 201 8-03-19 11:28:00 '), ' V ' =>array (' uid ' =>14, ' name ' = ' zhangsan3 ', ' ctime ' = ' 2018-03- 11:28:00 '), ' C ' =>array (' uid ' =>14, ' name ' = ' zhangsan3 ', ' ctime ' = ' 2018-03-22 11 : 28:00 '), $ctime _str = Array (), foreach ($arr as $key = = $v) {$arr [$key] [' ctime_str '] = strtotime ($v [' CTime ']); $ctime _str[] = $arr [$key] [' ctime_str '];} Array_multisort ($ctime _str,sort_desc, $arr); Annotations: $ctime _str is the first array, similar to the one in SQL sort, whichever is first, order by Id,ctime | | | $arr is the second array of
Print_r ($arr);
Printing results:
Related recommendations:
PHP Two-dimensional array time ordering implementation code
PHP Remote file Management, you can sort tables, traverse directories, time sequencing _php tutorial