我必须过滤此数组以仅查看将来的项目。 如何取消设置timeEnd已过期的项目? 即当我在17:00调用这个数组时,只剩下数组[2]。
阵 ( [0] =>排列 ( [id] => 3034 [date] => 28-09-2016 [timeStart] => 08:30 [timeEnd] => 09:30 [描述] => USER_A [locationId] => 1 [roomId] => 8 [relationId] => 104 )
[1] => Array
(
[id] => 2524
[date] => 28-09-2016
[timeStart] => 08:30
[timeEnd] => 12:00
[description] => User_B
[locationId] => 1
[roomId] => 5
[relationId] => 86
)
[2] => Array
(
[id] => 2533
[date] => 28-09-2016
[timeStart] => 09:00
[timeEnd] => 18:00
[description] => User_C
[locationId] => 1
[roomId] => 4
[relationId] => 31
)
)
答案 0 :(得分:0)
foreach ($reservations as $key=>$reservation) {
$expireDate = $reservation['date'].' '.$reservation['timeEnd'];
if (strtotime($expireDate) <= strtotime('now')){
unset($reservations[$key]);
}
}