通过数组排序时间戳PHP [英] Array Sorting PHP by timestamp

查看:143
本文介绍了通过数组排序时间戳PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题,在订购我想要的方式数组。

I have problem ordering an array in the way I want.

这是我的数组的一个示例输出: http://pastebin.com/GJNBmqL7

This is an example output of my array: http://pastebin.com/GJNBmqL7

数据来自各种数据库一次,所以我在我把数据放入数组的方式有限。

Data comes from various database at once, so I'm limited in the way that I put the data into the array.

在[2]总是包含一个Linux时间戳。现在我想整个数组由该时间戳进行排序,最低值第一。

The [2] always contains a linux timestamp. Now I want the entire array to be ordered by that timestamp, with the lowest value first.

我如何做呢?

推荐答案

下面的的在array_multisort 例如:

foreach ($array as $key => $node) {
   $timestamps[$key]    = $node[2];
}
array_multisort($timestamps, SORT_ASC, $array);

这篇关于通过数组排序时间戳PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆