我想我的爆炸陣列看起來像這樣:PHP爆炸陣列陣列具有四個細胞
[0] => Array
(
[0] => 14 // this is hours
[1] => 38 // this is minutes
[2] => 14 // this is hours again
[3] => 59 // this is minutes again
)
[1] => Array
(
[0] => 15 // this is hours
[1] => 10 // this is minutes
[2] => 16 // this is hours again
[3] => 40 // this is minutes again
)
.
.
.
[200] => Array
(
[0] => 13 // this is hours
[1] => 35 // this is minutes
[2] => 23 // this is hours again
[3] => 32 // this is minutes again
)
這個,因爲我將在未來這些時間進行比較。
我有這樣的時間的列表:
15:48,16:10 12:01,12:19 13:06,13:28 10:45,11:02
,現在我明白了一個數組,它看起來像這樣的:
[0] => 16:10,16:36
[1] => 13:06,13:17
.
.
.
[200] => 14:38,14:59
我曾嘗試迄今
$length = count($timesArr);
for($i=0; $i < $length; $i++){
foreach (explode(',', $timesArr[$i]) as $piece) {
$timesArray[] = explode(':', $piece);
}
}
和因爲結果輸出是這樣的,這是相當接近:
[0] => Array
(
[0] => 14
[1] => 38
)
[1] => Array
(
[0] => 14
[1] => 59
)
所以再次主要問題是,我所需要的細胞在0和1的上方作爲認爲是在同一小區
我也可以直接從字符串去,所以我會爆炸字符串。
你可以使用'preg_replace_callback()'來處理它的正則表達式 – Martijn