3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $html = <<<'HTML' <div id='makeme' class='testme'> <span id='whatspanID'>somthing</span> <p class='ptagclass'></p> </div> HTML; $dom = new DOMDocument(); $dom->loadHtml($html); $xpath = new DOMXpath($dom); $div = $xpath->evaluate('//div[@id="makeme"]')->item(0); $nodes = $xpath->evaluate('.//text()|.//@*', $div); $length = count($nodes); for($i = $length - 1; $i >= 0, --$i) { $node->parentNode->removeChild($node); } echo $dom->saveHtml($div);
Output for 5.3.0 - 5.4.28
Parse error: syntax error, unexpected ')', expecting ';' in /in/1ojXM on line 17
Process exited with code 255.