3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <body> <div>foo</div> <shortcode type="content" /> <div>bar</div> </body> HTML; $replace = <<<HTML <div>content</div> HTML; $dom = new DOMDocument(); libxml_use_internal_errors(true); $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); echo $dom->saveHTML($dom->documentElement); echo PHP_EOL, '---------------------------', PHP_EOL; $xpath = new DOMXPath($dom); $nodes = $xpath->query('//shortcode'); foreach($nodes as $node) { $newHTML = $dom->createDocumentFragment(); $newHTML->appendXML($replace); $node->parentNode->insertBefore($newHTML, $node); $node->parentNode->removeChild($node); } echo $dom->saveHTML($dom->documentElement);
Output for git.master, git.master_jit, rfc.property-hooks
<body> <div>foo</div> <shortcode type="content"></shortcode> <div>bar</div> </body> --------------------------- <body> <div>foo</div> <div>content</div> <div>bar</div> </body>

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
85.32 ms | 401 KiB | 8 Q