3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /* Just compose the HTML sample */ $html='<html><head></head><body><table id="myTable" style="table-layout:fixed;" class="table-list"> <colgroup> <col width="70px"> <col width="70px"> <col width="70px"> <col width="70px"> <col width="70px"> <col width="70px"> <col width="70px"> <col width="70px"> <col width="70px"> <col width="70px"> <col width="70px"> <col width="70px"> <col width="70px"> <col width="70px"> </colgroup> <thead> <tr> <th colspan="14">Waktu</th> </tr> <tr> <th>00:00</th> <th>01:00</th> <th>02:00</th> <th>03:00</th> <th>04:00</th> <th>05:00</th> <th>06:00</th> <th>07:00</th> <th>08:00</th> <th>09:00</th> <th>10:00</th> <th>11:00</th> <th>12:00</th> <th>13:00</th> </tr> </thead> <tbody> <tr><td style="background-color:#91ff66">40 G </td><td style="background-color:#91ff66">30 MT </td><td style="background-color:#91ff66">30 MT </td><td style="background-color:#91ff66">30 M </td><td style="background-color:#91ff66">30 MT </td><td style="background-color:#91ff66">30 MT </td><td style="background-color:#91ff66">30 MT </td><td style="background-color:#91ff66">30 MT </td><td style="background-color:#91ff66">20 T </td><td style="background-color:#91ff66">20 T </td><td style="background-color:#91ff66">20 T </td><td style="background-color:#91ff66">20 T </td><td style="background-color:#91ff66">20 T </td><td style="background-color:#91ff66">20 T </td></tr><tr><td style="background-color:#91ff66">125 M </td><td style="background-color:#91ff66">125 M </td><td style="background-color:#91ff66">125 MT </td><td style="background-color:#91ff66">125 MT </td><td style="background-color:#91ff66">125 MT </td><td style="background-color:#91ff66">125 MT </td><td style="background-color:#91ff66">120 T </td><td style="background-color:#91ff66">120 T </td><td style="background-color:#91ff66">120 T </td><td style="background-color:#91ff66">120 T </td><td style="background-color:#91ff66">120 T </td><td style="background-color:#91ff66">120 T </td><td style="background-color:#91ff66">120 T </td><td style="background-color:#91ff66">120 T </td></tr><tr><td style="background-color:#91ff66">670 MT </td><td style="background-color:#91ff66">670 MT </td><td style="background-color:#91ff66">650 MT </td><td style="background-color:#91ff66">650 MT </td><td style="background-color:#91ff66">650 MT </td><td style="background-color:#91ff66">650 MT </td><td style="background-color:#91ff66">650 MT </td><td style="background-color:#91ff66">650 MT </td><td style="background-color:#91ff66">650 MT </td><td style="background-color:#91ff66">670 T </td><td style="background-color:#91ff66">670 T </td><td style="background-color:#91ff66">660 T </td><td style="background-color:#91ff66">660 T </td><td style="background-color:#91ff66">650 T </td></tr><tr><td style="background-color:#91ff66">400 M </td><td style="background-color:#91ff66">400 M </td><td style="background-color:#91ff66">400 M </td><td style="background-color:#91ff66">400 M </td><td style="background-color:#91ff66">400 MT </td><td style="background-color:#91ff66">400 MT </td><td style="background-color:#91ff66">390 MT </td><td style="background-color:#91ff66">390 MT </td><td style="background-color:#91ff66">390 T </td><td style="background-color:#91ff66">390 T </td><td style="background-color:#91ff66">390 T </td><td style="background-color:#91ff66">390 T </td><td style="background-color:#91ff66">390 T </td><td style="background-color:#91ff66">390 T </td></tr><tr><td style="background-color:#91ff66">70 G </td><td style="background-color:#91ff66">70 G </td><td style="background-color:#91ff66">70 G </td><td style="background-color:#91ff66">70 G </td><td style="background-color:#91ff66">70 MT </td><td style="background-color:#91ff66">70 MT </td><td style="background-color:#91ff66">70 MT </td><td style="background-color:#91ff66">70 MT </td><td style="background-color:#91ff66">70 MT </td><td style="background-color:#91ff66">70 T </td><td style="background-color:#91ff66">70 T </td><td style="background-color:#91ff66">70 T </td><td style="background-color:#91ff66">50 T </td><td style="background-color:#91ff66">50 T </td></tr><tr><td style="background-color:#91ff66">90 M </td><td style="background-color:#91ff66">90 M </td><td style="background-color:#91ff66">90 MT </td><td style="background-color:#91ff66">85 MT </td><td style="background-color:#91ff66">85 MT </td><td style="background-color:#91ff66">85 MT </td><td style="background-color:#91ff66">85 MT </td><td style="background-color:#91ff66">85 MT </td><td style="background-color:#91ff66">80 T </td><td style="background-color:#91ff66">80 T </td><td style="background-color:#91ff66">80 T </td><td style="background-color:#91ff66">80 T </td><td style="background-color:#91ff66">80 T </td><td style="background-color:#91ff66">80 T </td></tr><tr><td style="background-color:#91ff66">50 M </td><td style="background-color:#91ff66">50 M </td><td style="background-color:#91ff66">50 M </td><td style="background-color:#91ff66">40 MT </td><td style="background-color:#91ff66">40 T </td><td style="background-color:#91ff66">40 T </td><td style="background-color:#91ff66">40 T </td><td style="background-color:#91ff66">40 T </td><td style="background-color:#91ff66">40 T </td><td style="background-color:#91ff66">40 T </td><td style="background-color:#91ff66">40 T </td><td style="background-color:#91ff66">40 T </td><td style="background-color:#91ff66">40 T </td><td style="background-color:#91ff66">40 T </td></tr><tr><td style="background-color:#91ff66">-195 MT </td><td style="background-color:#91ff66">-195 MT </td><td style="background-color:#91ff66">-195 MT </td><td style="background-color:#91ff66">-195 MT </td><td style="background-color:#91ff66">-195 MT </td><td style="background-color:#91ff66">-195 MT </td><td style="background-color:#91ff66">-195 MT </td><td style="background-color:#91ff66">-195 MT </td><td style="background-color:#91ff66">-195 T </td><td style="background-color:#91ff66">-195 T </td><td style="background-color:#91ff66">-195 T </td><td style="background-color:#91ff66">-195 T </td><td style="background-color:#91ff66">-195 T </td><td style="background-color:#91ff66">-195 T </td></tr><tr><td style="background-color:#91ff66">154 M </td><td style="background-color:#91ff66">154 M </td><td style="background-color:#91ff66">164 T </td><td style="background-color:#ffff66">170 T </td><td style="background-color:#ffff66">175 T </td><td style="background-color:#ffff66">182 T </td><td style="background-color:#ffff66">184 T </td><td style="background-color:#ffff66">184 T </td><td style="background-color:#ffcc00">209 T </td><td style="background-color:#ffff66">190 T </td><td style="background-color:#ffff66">190 T </td><td style="background-color:#ffff66">190 T </td><td style="background-color:#ffff66">188 T </td><td style="background-color:#91ff66">161 T </td></tr><tr><td style="background-color:#91ff66">90 G </td><td style="background-color:#91ff66">90 G </td><td style="background-color:#91ff66">90 G </td><td style="background-color:#91ff66">90 G </td><td style="background-color:#91ff66">90 MT </td><td style="background-color:#91ff66">90 MT </td><td style="background-color:#91ff66">90 MT </td><td style="background-color:#91ff66">90 MT </td><td style="background-color:#91ff66">90 MT </td><td style="background-color:#91ff66">90 T </td><td style="background-color:#91ff66">90 T </td><td style="background-color:#91ff66">90 T </td><td style="background-color:#91ff66">90 T </td><td style="background-color:#91ff66">90 T </td></tr><tr><td style="background-color:#91ff66">70 M </td><td style="background-color:#91ff66">70 M </td><td style="background-color:#91ff66">70 M </td><td style="background-color:#91ff66">70 M </td><td style="background-color:#91ff66">70 MT </td><td style="background-color:#91ff66">70 MT </td><td style="background-color:#91ff66">55 MT </td><td style="background-color:#91ff66">55 MT </td><td style="background-color:#91ff66">55 MT </td><td style="background-color:#91ff66">55 MT </td><td style="background-color:#91ff66">55 MT </td><td style="background-color:#91ff66">55 MT </td><td style="background-color:#91ff66">55 MT </td><td style="background-color:#91ff66">55 MT </td></tr><tr><td style="background-color:#91ff66">390 MT </td><td style="background-color:#91ff66">390 MT </td><td style="background-color:#91ff66">390 MT </td><td style="background-color:#91ff66">390 MT </td><td style="background-color:#91ff66">390 MT </td><td style="background-color:#91ff66">390 MT </td><td style="background-color:#91ff66">390 MT </td><td style="background-color:#91ff66">390 MT </td><td style="background-color:#91ff66">390 MT </td><td style="background-color:#91ff66">390 MT </td><td style="background-color:#91ff66">370 T </td><td style="background-color:#91ff66">370 T </td><td style="background-color:#91ff66">370 T </td><td style="background-color:#91ff66">370 T </td></tr> </tbody> </table></body></html>"; $doc=new DOMDocument(); $doc->loadHTML($html); $xpath=new DOMXPath($doc); echo "<table>\n"; /* 10 is the row count */ for($i=0;$i<10;$i++) { echo "<tr>\n"; /* 10 is the column count */ foreach($xpath->query('//table[@id="myTable"]/tr[position()>'.($i*10).' and position()<'.(($i+1)*10+1).']') as $tr) { echo "\t<td>";// "\t" to make it look nice $tds=array(); foreach($tr->childNodes as $td) { if($td->nodeName!="td") continue; $tds[]=$td->firstChild->nodeValue; } echo implode("<br />",$tds); echo "</td>\n"; } echo "</tr>\n"; } echo "</table>";
based on lrOLg
Output for 7.0.0
Parse error: syntax error, unexpected 'echo' (T_ECHO) in /in/97UF9 on line 55
Process exited with code 255.
Output for 5.3.20 - 5.6.16
Parse error: syntax error, unexpected '{' in /in/97UF9 on line 54
Process exited with code 255.