3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $id= array("1","2","3","4","5","6","7","8","9","10","11","12"); $maxcols = 8; $i = 0;$j=0;$t=0;$s=0; $maxid = count($id); echo "<table id='table1'>\n<tr>"; foreach ($id as $k => $v) { if($t == 0) { while ($t <= $maxcols-1) { if($s < $maxid) { $s++;$t++; echo "<td class='mark'>id$s</td>"; } else { echo "<td class='mark'></td>";$t++;$s++; } } echo "</tr><tr>"; } else { } echo "<td id='0'><div id=$k+1 class='drag t1'>{$v}</div></td>"; $i++; if ($i == $maxcols) { echo "</tr>\n<tr>"; if($j == 0) { while ($j <= $maxcols-1) { if($s < $maxid) { $s++;$j++; echo "<td class='mark'>id$s</td>"; } else { echo "<td class='mark'></td>";$j++;$s++; } } echo "</tr>\n<tr>"; } $i=0; } } echo "</tr>\n</table>"; ?>
Output for 4.3.0 - 7.1.0
<table id='table1'> <tr><td class='mark'>id1</td><td class='mark'>id2</td><td class='mark'>id3</td><td class='mark'>id4</td><td class='mark'>id5</td><td class='mark'>id6</td><td class='mark'>id7</td><td class='mark'>id8</td></tr><tr><td id='0'><div id=0+1 class='drag t1'>1</div></td><td id='0'><div id=1+1 class='drag t1'>2</div></td><td id='0'><div id=2+1 class='drag t1'>3</div></td><td id='0'><div id=3+1 class='drag t1'>4</div></td><td id='0'><div id=4+1 class='drag t1'>5</div></td><td id='0'><div id=5+1 class='drag t1'>6</div></td><td id='0'><div id=6+1 class='drag t1'>7</div></td><td id='0'><div id=7+1 class='drag t1'>8</div></td></tr> <tr><td class='mark'>id9</td><td class='mark'>id10</td><td class='mark'>id11</td><td class='mark'>id12</td><td class='mark'></td><td class='mark'></td><td class='mark'></td><td class='mark'></td></tr> <tr><td id='0'><div id=8+1 class='drag t1'>9</div></td><td id='0'><div id=9+1 class='drag t1'>10</div></td><td id='0'><div id=10+1 class='drag t1'>11</div></td><td id='0'><div id=11+1 class='drag t1'>12</div></td></tr> </table>