3v4l.org

run code in 300+ PHP versions simultaneously
<?php <?php $html = <<<HTML <div> <div> <p> ... </p> </div> </div> HTML; $dom = new DOMDocument; $dom->loadHTML($html); $xpath = new DOMXPath($dom); $nodes = $xpath->query('//*'); foreach ($nodes as $node) { printf( "Nodes in List: %d \n" . "Current Tag: %s \n" . "Current Parent: %s \n\n", $nodes->length, $node->tagName, $node->parentNode->tagName ); $node->parentNode->removeChild($node); } echo $dom->saveHtml();
Output for 5.3.0 - 5.3.26, 5.4.0 - 5.4.16
Parse error: syntax error, unexpected '<' in /in/91IcK on line 2
Process exited with code 255.

preferences:
181.17 ms | 1395 KiB | 51 Q