3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $html=<<<HTML <html> <body> <table id="news" width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="539" height="35"><span><strong>Info to Extract</strong></span></td> </tr> <tr> <td height="35" class="texto10">Martes, 02 de Octubre de 2012 | Autor: Trovert</td> </tr> <tr> <td height="35" class="texto12Gris"><p><strong>Info To extract</strong></p> <p><strong>&nbsp;</strong></p> <p><strong>Casa de Gobierno: (a 9 cuadras del hostel)</strong></p> <img title="title" src="../images/theimage.jpg" width="400" height="266" /> </td> </tr> </table> </body> </html> HTML; function walkNode($node) { $str=""; if($node->nodeType==XML_TEXT_NODE) { $str.=$node->nodeValue; } elseif(strtolower($node->nodeName)=="img") { $str.='<img src="'.$node->attributes->getNamedItem("src")->nodeValue.'" />'; } if($node->firstChild) $str.=walkNode($node->firstChild); if($node->nextSibling) $str.=walkNode($node->nextSibling); return $str; } $dom=new DOMDocument(); $dom->loadHTML($html); $xpath=new DOMXPath($dom); $tds=$xpath->query('//table[@id="news"]//tr[position()>0]/td'); foreach($tds as $td) { echo walkNode($td->firstChild); echo "\n"; }
Output for 5.0.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Info to Extract Martes, 02 de Octubre de 2012 | Autor: Trovert Info To extract   Casa de Gobierno: (a 9 cuadras del hostel) <img src="../images/theimage.jpg" />
Output for 4.4.3 - 4.4.9
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/mIZer on line 33
Process exited with code 255.
Output for 4.4.2
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/mIZer on line 34
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/mIZer on line 33
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/mIZer on line 33
Process exited with code 255.