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); $table0 = array(); $table1 = array(); foreach($xpath->query('//table[@class="grilla"]') as $key => $table){ $table = "table$key"; foreach($xpath->query("tbody/tr/td/text()", $table) as $node){ array_push($$table, $node->nodeValue); } }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Fatal error: Uncaught TypeError: DOMXPath::query(): Argument #2 ($contextNode) must be of type ?DOMNode, string given in /in/UTUpc:54 Stack trace: #0 /in/UTUpc(54): DOMXPath->query('tbody/tr/td/tex...', 'table0') #1 {main} thrown in /in/UTUpc on line 54
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Fatal error: Uncaught TypeError: DOMXPath::query(): Argument #2 ($contextNode) must be of type ?DOMNode, string given in /in/UTUpc:54 Stack trace: #0 /in/UTUpc(54): DOMXPath->query('tbody/tr/td/tex...', 'table0') #1 {main} thrown in /in/UTUpc on line 54
Process exited with code 255.
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught TypeError: Argument 2 passed to DOMXPath::query() must be an instance of DOMNode or null, string given in /in/UTUpc:54 Stack trace: #0 /in/UTUpc(54): DOMXPath->query('tbody/tr/td/tex...', 'table0') #1 {main} thrown in /in/UTUpc on line 54
Process exited with code 255.
Output for 7.0.0 - 7.0.33
Fatal error: Uncaught TypeError: Argument 2 passed to DOMXPath::query() must be an instance of DOMNode, string given in /in/UTUpc:54 Stack trace: #0 /in/UTUpc(54): DOMXPath->query('tbody/tr/td/tex...', 'table0') #1 {main} thrown in /in/UTUpc on line 54
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Catchable fatal error: Argument 2 passed to DOMXPath::query() must be an instance of DOMNode, string given in /in/UTUpc on line 54
Process exited with code 255.

preferences:
275.78 ms | 402 KiB | 330 Q