3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $myHtml = ' <div class="div-class"> <p>text</p> <p><a href="#">text</a></p> </div> <ul class="some-class"> <li><a href="#" target="_blank" title="something something"><img src="" alt=""></a> </li> <li><a href="" target="_blank" title=""><img src="" alt=""></a> </li> <li><a href="" target="_blank" title=""><img src=""></a> </li> </ul> '; $doc = new \DOMDocument(); $doc->loadHTML($myHtml, LIBXML_HTML_NODEFDTD); var_dump (libxml_get_errors()); $xpath = new \DOMXPath($doc); $anchors = $xpath->query("//a[@title='something something']"); $list = $xpath->query("//ul[@class='some-class']")[0]; foreach ($anchors as $a) { $list->removeChild($a->parentNode); } var_dump($doc->saveHTML());
Output for 5.6.3 - 5.6.30, 7.0.0 - 7.3.0rc3
array(0) { } string(292) "<html><body><div class="div-class"> <p>text</p> <p><a href="#">text</a></p> </div> <ul class="some-class"> <li><a href="" target="_blank" title=""><img src="" alt=""></a> </li> <li><a href="" target="_blank" title=""><img src=""></a> </li> </ul> </body></html> "
Output for hhvm-3.22.0
array(0) { } Fatal error: Uncaught Error: Object does not implement ArrayAccess in /in/cGN4n:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
array(0) { } Fatal error: Uncaught Error: Object does not implement ArrayAccess in /in/cGN4n:25 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.2
array(0) { } Fatal error: Cannot use object of type DOMNodeList as array in /in/cGN4n on line 25
Process exited with code 255.