3v4l.org

run code in 300+ PHP versions simultaneously
<?php $doc = "<g> <svg> <g><path/></g> <g><circle/></g> </svg> <svg> <g><circle/></g> </svg> <svg> <g><circle2/></g> </svg> </g>"; $dom = new DOMDocument(); $dom->loadXML($doc); $x = new DOMXPath($dom); $toDelete = $x->query("//svg[not(.//path)]"); foreach ($toDelete as $child) { var_dump($child); $child->parentNode->removeChild($child); } var_dump($dom->saveXML());
Output for git.master, git.master_jit, rfc.property-hooks
object(DOMElement)#3 (23) { ["schemaTypeInfo"]=> NULL ["tagName"]=> string(3) "svg" ["firstElementChild"]=> string(22) "(object value omitted)" ["lastElementChild"]=> string(22) "(object value omitted)" ["childElementCount"]=> int(1) ["previousElementSibling"]=> string(22) "(object value omitted)" ["nextElementSibling"]=> string(22) "(object value omitted)" ["nodeName"]=> string(3) "svg" ["nodeValue"]=> string(14) " " ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> string(22) "(object value omitted)" ["lastChild"]=> string(22) "(object value omitted)" ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(3) "svg" ["baseURI"]=> string(1) "/" ["textContent"]=> string(14) " " } object(DOMElement)#4 (23) { ["schemaTypeInfo"]=> NULL ["tagName"]=> string(3) "svg" ["firstElementChild"]=> string(22) "(object value omitted)" ["lastElementChild"]=> string(22) "(object value omitted)" ["childElementCount"]=> int(1) ["previousElementSibling"]=> string(22) "(object value omitted)" ["nextElementSibling"]=> NULL ["nodeName"]=> string(3) "svg" ["nodeValue"]=> string(14) " " ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> string(22) "(object value omitted)" ["lastChild"]=> string(22) "(object value omitted)" ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(3) "svg" ["baseURI"]=> string(1) "/" ["textContent"]=> string(14) " " } string(110) "<?xml version="1.0"?> <g> <svg> <g><path/></g> <g><circle/></g> </svg> </g> "

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:
48.69 ms | 409 KiB | 8 Q