3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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">13115 - 2010</td> </tr> </tbody></table>'; $html.="</body></html>"; $doc=new DOMDocument(); $doc->loadHTML($html); $xpath=new DOMXPath($doc); $tds = array(); foreach($xpath->query('//table[@class="grilla"]/tbody/tr/td/text()') as $key => $td) { array_push($tds, $td->nodeValue); } print_r(array_unique(array_chunk($tds, 2)));
based on WXaFL
Output for 7.2.0
Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Array ( [0] => Array ( [0] => 2 JPL PROVIDENCIA [1] => 018092 - 2010 ) )
Output for 7.0.0 - 7.1.10
Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Array ( [0] => Array ( [0] => 2 JPL PROVIDENCIA [1] => 018092 - 2010 ) )
Output for 5.4.10 - 5.6.28
Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Notice: Array to string conversion in /in/FKPne on line 54 Array ( [0] => Array ( [0] => 2 JPL PROVIDENCIA [1] => 018092 - 2010 ) )
Output for 5.3.20 - 5.3.29
Array ( [0] => Array ( [0] => 2 JPL PROVIDENCIA [1] => 018092 - 2010 ) )