3v4l.org

run code in 300+ PHP versions simultaneously
<?php $times = [ "opening_time" => [ "monday" => ["10:30 am", "6:30 pm"], "tuesday" => ["12:30 pm"], "wednesday" => ["4:30 pm"], "thursday" => ["2:30 pm"], "friday" => ["4:00 pm"], "saturday" => ["6:00 am"], "sunday" => [] ], "closing_time" => [ "monday" => ["6:00 pm", "10:30 pm"], "tuesday" => ["7:00 pm"], "wednesday" => ["10:00 pm"], "thursday" => ["6:30 pm"], "friday" => ["11:00 pm"], "saturday" => ["6:00 pm"], "sunday" => [] ] ]; $slots = max(array_map('count', $times['opening_time'])); echo '<table border=2 cell-padding=5>' ."\n"; foreach ($times['opening_time'] as $day => $opens) { echo "\t<tr><td>$day</td>"; for ($i = 0; $i < $slots; ++$i) { printf( '<td>%s</td>', implode( ' to ', [ ...(array) ($opens[$i] ?? []), ...(array) ($times['closing_time'][$day][$i] ?? []) ] ) ); } echo "</tr>\n"; } echo '</table>';

preferences:
25.68 ms | 407 KiB | 5 Q