Array
(
[0] => Array
(
[id] => 17
[uid] => 54915a9f4f26e
[unixtimestamp] => 1408210200
)
[1] => Array
(
[id] => 26
[uid] => 54915a9f519a2
[unixtimestamp] => 1408815000
)
)
这是我的数组,我想按unix时间戳顺序对它们进行排序。
如何告诉我要对特定的unix时间戳元素进行排序的PHP排序函数?
sort($myarray); // how to tell sort by unixtimestamp?
答案 0 :(得分:2)
使用usort()
function sortByOrder($a, $b) {
return $a['unixtimestamp'] - $b['unixtimestamp'];
}
usort($myArray, 'sortByOrder');
$ myArray是你的数组