3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <html> <body> <div class="regular-box">DIV 0</div> <div class="comments-box">DIV 1</div> <div class="heycomments-box">DIV 2</div> <div class="sdfcomments-box">DIV 3</div> <div class="sdgsdgcomments-boxsdfdfh">DIV 4</div> </body> </html> HTML; $dom = new DOMDocument; $dom->loadHTML($html, LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED); $xp = new DOMXPath($dom); // get the node list of div nodes with "target" class $spanNodeList = $xp->query('//div[contains(@class, "comments-box")]'); foreach ($spanNodeList as $spanNode) { $spanNode->parentNode->replaceChild($spanNode->firstChild, $spanNode); } echo $dom->saveHTML();
Output for git.master, git.master_jit, rfc.property-hooks
<html> <body> <div class="regular-box">DIV 0</div> DIV 1 DIV 2 DIV 3 DIV 4 </body> </html>

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:
55.57 ms | 401 KiB | 8 Q