我有下一个数组:
Array (
[15709] => stdClass Object (
[pid] => 15709
[channel_ID] => 51
[date] => 2016-03-21 00:30:00
[program_info] => Х/ф "Стелла" )
[15710] => stdClass Object (
[pid] => 15710 [channel_ID] => 51
[date] => 2016-03-21 02:20:00
[program_info] => Х/ф "Часы доблести" )
[15711] => stdClass Object (
[pid] => 15711
[channel_ID] => 51
[date] => 2016-03-21 06:15:00
[program_info] => Фильм-концерт "Хичкок. Концерт в магазине"
) )
我需要按字段[date]
对他进行排序,首先应该从指定的时间05:00:00开始查看元素,结果必须是这样的:
Array (
[15711] => stdClass Object (
[pid] => 15711
[channel_ID] => 51
[date] => 2016-03-21 06:15:00
[program_info] => Фильм-концерт "Хичкок. Концерт в магазине" )
[15709] => stdClass Object (
[pid] => 15709
[channel_ID] => 51
[date] => 2016-03-21 00:30:00
[program_info] => Х/ф "Стелла")
[15710] => stdClass Object (
[pid] => 15710 [channel_ID] => 51
[date] => 2016-03-21 02:20:00
[program_info] => Х/ф "Часы доблести"
) )
答案 0 :(得分:1)
尝试这样的事情:
uasort($myarray, function($a, $b) {
if ($a['date'] == $b['date']) {
return 0;
}
return ($a['date'] < $b['date']) ? -1 : 1;
})