3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = <<<DATA <div> <p>سلام</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(mb_convert_encoding($data, 'HTML-ENTITIES', 'UTF-8'), 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($dom->documentElement);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: mb_convert_encoding(): Handling HTML entities via mbstring is deprecated; use htmlspecialchars, htmlentities, or mb_encode_numericentity/mb_decode_numericentity instead in /in/A3Ck1 on line 15 <div> <p>سلام</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:
123.55 ms | 406 KiB | 5 Q