編輯新:我找到了自己的答案。
對於喜歡知道我是如何做到這一點的人。
- 獲取任何時候都
- 檢查最後的時間等於當前時間 - 1小時(所以這將是接下來的一個小時)
- 如果是 - >如果沒有刪除最後一個數組值
- - >這將意味着有最小的2個小時的差距如此之近TIMERANGE(推上一個數組值)
- 現在你有所有timeranges
Array ([0] => 04:00 [1] => 04:00 [2] => 09:00 [3] => 14:00 [4] => 18:00 [5] => 20:00)
- 片陣列通過2用for循環數組計數(陣列)次數。
- 然後你有特定的時間範圍。
Iam非常不好的解釋的東西,Iam對不起。 我現在代碼:
$last_v = null;
$array_times = array();
- $ van_besch =一個數據庫中獲取價值 -
if (strtotime($last_v) == (strtotime($van_besch) - 60*60)) {
array_pop($array_times);
}else{
array_push($array_times, $van_besch);
}
$last_v = $van_besch;
array_push($array_times, $van_besch);
如果每個值推入陣列。切片的數組:
for ($i =0; $i < count($array_times); $i = $i + 2) {
$new_array_1 = array_slice($array_times, $i, 2);
$van_new = $new_array_1[0];
$tot_new = $new_array_1[1];
if (strtotime($van) <= strtotime($tot) && strtotime($van_new) <= strtotime($tot_new) && strtotime($van) < strtotime($tot_new) && strtotime($tot) > strtotime($van_new)) {
$error ='<div style="background-color:#ffccba; border:2px solid #d63301; border-radius:3px; color:#d63301; padding:5px;">Tijd '.$van_new.' - '.$tot_new.' niet beschikbaar!</div>';
}
}
蔭高興的是,我找到了解決辦法我自己(:
你的例子是有點不可思議,因爲時間介於您提供實際上並不重疊,它們不應該被合併。 – HZS
必須有1小時的差距?也就是說'10:00-13:00'之間不會有數據像'10:30 - 11:45' –
正確,只有一小時的差距 –