There are two possibilities I can see for combining both arrays.
Option 1 is to combine the corresponding items from each array...
$hour = [20,22,24];
$minute = [0,10,20];
$out = [];
foreach ( $hour as $key => $hr ) {
$out[] = $hr. ':'. str_pad( $minute[$key], 2, '0', STR_PAD_LEFT). ':00';
}
print_r($out);
which gives...
Array
(
[0] => 20:00:00
[1] => 22:10:00
[2] => 24:20:00
)
Option 2 is to combine all possibilities...
$out = [];
foreach ( $hour as $hr ) {
foreach ( $minute as $mnt ){
$out[] = $hr. ':'. str_pad( $mnt, 2, '0', STR_PAD_LEFT). ':00';
}
}
print_r($out);
which gives...
Array
(
[0] => 20:00:00
[1] => 20:10:00
[2] => 20:20:00
[3] => 22:00:00
[4] => 22:10:00
[5] => 22:20:00
[6] => 24:00:00
[7] => 24:10:00
[8] => 24:20:00
)
As they are both integers, I use str_pad()
on the minutes to ensure that it is always 2 digits. You could do the same with the hours if you needed to.