I'm trying to explode my array to look like this:
[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
)
This because i will compare these times in the future.
I have list of times like this:
15:48,16:10 12:01,12:19 13:06,13:28 10:45,11:02
And now i got it in a array which looks like this:
[0] => 16:10,16:36
[1] => 13:06,13:17
.
.
.
[200] => 14:38,14:59
What i have tried so far
$length = count($timesArr);
for($i=0; $i < $length; $i++){
foreach (explode(',', $timesArr[$i]) as $piece) {
$timesArray[] = explode(':', $piece);
}
}
and this is quite close because the result output is like this:
[0] => Array
(
[0] => 14
[1] => 38
)
[1] => Array
(
[0] => 14
[1] => 59
)
so again the main problem is that i need as seen above the cells 0 and 1 to be in the same cell
I can also go for it straight from string so i would be exploding strings then.
preg_replace_callback()
to process it – Martijn Feb 27 '14 at 20:02