3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = <<<'EOT' <prefix name="forum" label="Forum" language_tag="en" language_label="English"> <key name="activity_string"> <value><a href="{$userUrl}">{$user}</a> <a href="{$url}">replied</a> in <a href="{$topicUrl}">{$topicTitle}</a> forum topic</value> </key> <key name="activity_string_topic"> <value><a href="{$userUrl}">{$user}</a> started new discussion: <a href="{$topicUrl}">{$topicTitle}</a></value> </key> <key name="additional"> <value>Additional</value> </key> <key name="add_files"> <value>Add files</value> </key> </prefix> EOT; $xmlOutput = new DOMDocument(); $xmlInput = new DOMDocument(); $xmlInput->loadXML($xml); foreach($xmlInput->getElementsByTagName('key') as $key) { var_dump($key->firstChild); }
Output for 8.3.0 - 8.3.4, 8.3.6
object(DOMText)#6 (23) { ["wholeText"]=> string(2) " " ["data"]=> string(2) " " ["length"]=> int(2) ["previousElementSibling"]=> NULL ["nextElementSibling"]=> string(22) "(object value omitted)" ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["parentElement"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["isConnected"]=> bool(true) ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) " " } object(DOMText)#5 (23) { ["wholeText"]=> string(2) " " ["data"]=> string(2) " " ["length"]=> int(2) ["previousElementSibling"]=> NULL ["nextElementSibling"]=> string(22) "(object value omitted)" ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["parentElement"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["isConnected"]=> bool(true) ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) " " } object(DOMText)#6 (23) { ["wholeText"]=> string(2) " " ["data"]=> string(2) " " ["length"]=> int(2) ["previousElementSibling"]=> NULL ["nextElementSibling"]=> string(22) "(object value omitted)" ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["parentElement"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["isConnected"]=> bool(true) ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) " " } object(DOMText)#5 (23) { ["wholeText"]=> string(2) " " ["data"]=> string(2) " " ["length"]=> int(2) ["previousElementSibling"]=> NULL ["nextElementSibling"]=> string(22) "(object value omitted)" ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["parentElement"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["isConnected"]=> bool(true) ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) " " }
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 object(DOMText)#6 (23) { ["wholeText"]=> string(2) " " ["data"]=> string(2) " " ["length"]=> int(2) ["previousElementSibling"]=> NULL ["nextElementSibling"]=> string(22) "(object value omitted)" ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["parentElement"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["isConnected"]=> bool(true) ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) " " } object(DOMText)#5 (23) { ["wholeText"]=> string(2) " " ["data"]=> string(2) " " ["length"]=> int(2) ["previousElementSibling"]=> NULL ["nextElementSibling"]=> string(22) "(object value omitted)" ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["parentElement"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["isConnected"]=> bool(true) ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) " " } object(DOMText)#6 (23) { ["wholeText"]=> string(2) " " ["data"]=> string(2) " " ["length"]=> int(2) ["previousElementSibling"]=> NULL ["nextElementSibling"]=> string(22) "(object value omitted)" ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["parentElement"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["isConnected"]=> bool(true) ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) " " } object(DOMText)#5 (23) { ["wholeText"]=> string(2) " " ["data"]=> string(2) " " ["length"]=> int(2) ["previousElementSibling"]=> NULL ["nextElementSibling"]=> string(22) "(object value omitted)" ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["parentElement"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["isConnected"]=> bool(true) ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) " " }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.18
object(DOMText)#6 (21) { ["wholeText"]=> string(2) " " ["data"]=> string(2) " " ["length"]=> int(2) ["previousElementSibling"]=> NULL ["nextElementSibling"]=> string(22) "(object value omitted)" ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) " " } object(DOMText)#5 (21) { ["wholeText"]=> string(2) " " ["data"]=> string(2) " " ["length"]=> int(2) ["previousElementSibling"]=> NULL ["nextElementSibling"]=> string(22) "(object value omitted)" ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) " " } object(DOMText)#6 (21) { ["wholeText"]=> string(2) " " ["data"]=> string(2) " " ["length"]=> int(2) ["previousElementSibling"]=> NULL ["nextElementSibling"]=> string(22) "(object value omitted)" ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) " " } object(DOMText)#5 (21) { ["wholeText"]=> string(2) " " ["data"]=> string(2) " " ["length"]=> int(2) ["previousElementSibling"]=> NULL ["nextElementSibling"]=> string(22) "(object value omitted)" ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) " " }
Output for 7.3.16 - 7.3.33, 7.4.4 - 7.4.33
object(DOMText)#6 (19) { ["wholeText"]=> string(2) " " ["data"]=> string(2) " " ["length"]=> int(2) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) " " } object(DOMText)#5 (19) { ["wholeText"]=> string(2) " " ["data"]=> string(2) " " ["length"]=> int(2) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) " " } object(DOMText)#6 (19) { ["wholeText"]=> string(2) " " ["data"]=> string(2) " " ["length"]=> int(2) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) " " } object(DOMText)#5 (19) { ["wholeText"]=> string(2) " " ["data"]=> string(2) " " ["length"]=> int(2) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) " " }
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.4.0 - 7.4.3
object(DOMText)#6 (19) { ["wholeText"]=> string(2) " " ["data"]=> string(2) " " ["length"]=> int(2) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) " " } object(DOMText)#5 (19) { ["wholeText"]=> string(2) " " ["data"]=> string(2) " " ["length"]=> int(2) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) " " } object(DOMText)#6 (19) { ["wholeText"]=> string(2) " " ["data"]=> string(2) " " ["length"]=> int(2) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) " " } object(DOMText)#5 (19) { ["wholeText"]=> string(2) " " ["data"]=> string(2) " " ["length"]=> int(2) ["nodeName"]=> string(5) "#text" ["nodeValue"]=> string(2) " " ["nodeType"]=> int(3) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> NULL ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> NULL ["baseURI"]=> string(1) "/" ["textContent"]=> string(2) " " }

preferences:
202.9 ms | 410 KiB | 171 Q