3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Just compose the HTML sample */ $html='<html><head></head><body>'; $html.='<table class="grilla"><tbody><tr class="textEncabezadoGrilla" bgcolor="#C0DAF1" align="center"> <th>Juzgado Policía Local</th> <th>Rol Causa</th> </tr> <tr> <td class="textgrid2">2 JPL PROVIDENCIA</td> <td class="textgrid2">018092 - 2010</td> </tr> <tr> <td class="textgrid1">OVALLE JPL</td> <td class="textgrid1">13115 - 2010</td> </tr> </tbody></table> <table class="grilla"><tbody><tr class="textEncabezadoGrilla" bgcolor="#C0DAF1" align="center"> <th>Juzgado Policía Local</th> <th>Rol Causa</th> </tr> <tr> <td class="textgrid2">2 JPL PROVIDENCIA</td> <td class="textgrid2">018092 - 2010</td> </tr> <tr> <td class="textgrid1">OVALLE JPL</td> <td class="textgrid1">13116 - 2011</td> </tr> </tbody></table>'; $html.="</body></html>"; $doc=new DOMDocument(); $doc->loadHTML($html); $xpath=new DOMXPath($doc); $tds = array(); var_dump($xpath->query('//table[@class="grilla"]/tbody/tr/td/text()')); foreach($xpath->query('//table[@class="grilla"]/tbody/tr/td/text()') as $key => $td) { array_push($tds, $td); } $print_r($tds); $ee = array_chunk($tds, 2);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
object(DOMNodeList)#11 (1) { ["length"]=> int(8) } Warning: Undefined variable $print_r in /in/3ONcI on line 55 Fatal error: Uncaught Error: Value of type null is not callable in /in/3ONcI:55 Stack trace: #0 {main} thrown in /in/3ONcI on line 55
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
object(DOMNodeList)#11 (1) { ["length"]=> int(8) } Notice: Undefined variable: print_r in /in/3ONcI on line 55 Fatal error: Uncaught Error: Function name must be a string in /in/3ONcI:55 Stack trace: #0 {main} thrown in /in/3ONcI on line 55
Process exited with code 255.
Output for 7.3.32 - 7.3.33
object(DOMNodeList)#11 (1) { ["length"]=> int(8) } Fatal error: Uncaught Error: Function name must be a string in /in/3ONcI:55 Stack trace: #0 {main} thrown in /in/3ONcI on line 55
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
object(DOMNodeList)#11 (1) { ["length"]=> int(8) } Notice: Undefined variable: print_r in /in/3ONcI on line 55 Fatal error: Function name must be a string in /in/3ONcI on line 55
Process exited with code 255.

preferences:
164.12 ms | 402 KiB | 225 Q