Detailed explanation of array time sorting in php

小云云
Release: 2023-03-21 21:12:02
Original
2559 people have browsed it

This article mainly shares with you the detailed explanation of array time sorting in PHP. I hope it can help you.

Ideas: 1.2018-03-20 16:19:00 Format.

2.php function array_multisort(); Sorting

$arr = array(    'a'=>array(           'uid'=>12,           'name'=>'zhangsan1',           'ctime'=>'2018-03-20 11:28:00'                ),    'b'=>array(        'uid'=>13,        'name'=>'zhangsan2',        'ctime'=>'2018-03-19 11:28:00'    ),    'v'=>array(        'uid'=>14,        'name'=>'zhangsan3',        'ctime'=>'2018-03-21 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);   批注:$ctime_str 是第一个数组,类似于sql排序中的,先以谁为准,order by id,ctime  ||| $arr是第二个数组
Copy after login
print_r($arr);
Copy after login

Print results:


相关推荐:
Copy after login
php 二维数组时间排序实现代码
Copy after login
<a href="http://www.php.cn/php-weizijiaocheng-310420.html" target="_self">PHP 远程文件管理,可以给表格排序,遍历目录,时间排序_PHP教程</a><br>
Copy after login

The above is the detailed content of Detailed explanation of array time sorting in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!