3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = <<<DATA <div> <p>These line shall stay</p> <p class="myclass">Remove this one</p> <p>But keep this</p> <div style="color: red">and this</div> <div style="color: red">and <p>also</p> this</div> <div style="color: red">and this <div style="color: red">too</div></div> </div> DATA; $dom = new DOMDocument(); $dom->loadHTML($data, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($dom); foreach ($xpath->query("//*[@*]") as $node) { $parent = $node->parentNode; while ($node->hasChildNodes()) { $parent->insertBefore($node->lastChild, $node->nextSibling); } $parent->removeChild($node); } echo $dom->saveHTML();
Output for git.master, git.master_jit, rfc.property-hooks
<div> <p>These line shall stay</p> Remove this one <p>But keep this</p> and this and <p>also</p> this and this too </div>

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