3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ ['start' => 1, 'name' => 'Test_name_1'], ['start' => 6, 'name' => 'Test_name_2'], ['start' => 22, 'name' => 'Test_name_3'], ['start' => 23, 'name' => 'Test_name_4'], ]; $hit = false; echo '<table>'; for($i = 1; $i <= 47; $i++) { echo '<tr>'; foreach($arr as $record) { if($record['start'] == $i) { $hit = true; echo '<td align="center" style="border-top: 1px solid black;"><b>' . $record['name'] . '</b> </td>'; echo '<td align="center" style="border-top: 1px solid black;">' . $i . ' </td>'; break; } } if(!$hit) { echo '<td align="center" style="border-top: 1px solid black;">blank </td>'; echo '<td align="center" style="border-top: 1px solid black;">' . $i . ' </td>'; } echo '</tr>'; $hit = false; } echo '</table>';
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.26, 8.1.0 - 8.1.13
<table><tr><td align="center" style="border-top: 1px solid black;"><b>Test_name_1</b> </td><td align="center" style="border-top: 1px solid black;">1 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">2 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">3 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">4 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">5 </td></tr><tr><td align="center" style="border-top: 1px solid black;"><b>Test_name_2</b> </td><td align="center" style="border-top: 1px solid black;">6 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">7 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">8 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">9 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">10 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">11 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">12 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">13 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">14 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">15 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">16 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">17 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">18 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">19 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">20 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">21 </td></tr><tr><td align="center" style="border-top: 1px solid black;"><b>Test_name_3</b> </td><td align="center" style="border-top: 1px solid black;">22 </td></tr><tr><td align="center" style="border-top: 1px solid black;"><b>Test_name_4</b> </td><td align="center" style="border-top: 1px solid black;">23 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">24 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">25 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">26 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">27 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">28 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">29 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">30 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">31 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">32 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">33 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">34 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">35 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">36 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">37 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">38 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">39 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">40 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">41 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">42 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">43 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">44 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">45 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">46 </td></tr><tr><td align="center" style="border-top: 1px solid black;">blank </td><td align="center" style="border-top: 1px solid black;">47 </td></tr></table>

preferences:
89.13 ms | 437 KiB | 6 Q