PHP Array Time sequencing detailed

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.