1 回答
TA贡献1821条经验 获得超6个赞
那又如何呢?
$dates = [
[
'event_date' => '2020-02-20 00:00:00',
'event_start_timet_date' => '09:14:00',
'event_end_time' => '13:14:00',
],
[
'event_date' => '2020-02-15 00:00:00',
'event_start_timet_date' => '09:15:00',
'event_end_time' => '11:15:00',
],
[
'event_date' => '2020-02-26 00:00:00',
'event_start_timet_date' => '14:15:00',
'event_end_time' => '18:15:00',
],
];
usort($dates, function(array $a, array $b) {
if (!isset($a['event_date']) || !isset($b['event_date'])) {
return 0;
}
return $a['event_date'] <=> $b['event_date'];
});
或者,如果您知道“event_date”将出现在该数组中(并且您有PHP 7.4),您可能想尝试一下这个
usort($dates, fn(array $a, array $b): int => $a['event_date'] <=> $b['event_date']);
- 1 回答
- 0 关注
- 80 浏览
添加回答
举报