3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $xml = '<items><item/><item/><item/></items>'; $dom = new DOMDocument(); $dom->loadXml($xml); $array = iterator_to_array($dom->documentElement->childNodes); var_dump(count($array), $array);
Output for 7.0.0 - 7.1.0
int(3) array(3) { [0]=> object(DOMElement)#5 (18) { ["tagName"]=> string(4) "item" ["schemaTypeInfo"]=> NULL ["nodeName"]=> string(4) "item" ["nodeValue"]=> string(0) "" ["nodeType"]=> int(1) ["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"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(4) "item" ["baseURI"]=> string(1) "/" ["textContent"]=> string(0) "" } [1]=> object(DOMElement)#6 (18) { ["tagName"]=> string(4) "item" ["schemaTypeInfo"]=> NULL ["nodeName"]=> string(4) "item" ["nodeValue"]=> string(0) "" ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["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(4) "item" ["baseURI"]=> string(1) "/" ["textContent"]=> string(0) "" } [2]=> object(DOMElement)#7 (17) { ["tagName"]=> string(4) "item" ["schemaTypeInfo"]=> NULL ["nodeName"]=> string(4) "item" ["nodeValue"]=> string(0) "" ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> string(22) "(object value omitted)" ["attributes"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(4) "item" ["baseURI"]=> string(1) "/" ["textContent"]=> string(0) "" } }
Output for hhvm-3.12.0
int(3) array(3) { [0]=> object(DOMElement)#5 (18) { ["nodeName"]=> string(4) "item" ["nodeValue"]=> string(0) "" ["nodeType"]=> int(1) ["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"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(4) "item" ["baseURI"]=> string(1) "/" ["textContent"]=> string(0) "" ["tagName"]=> string(4) "item" ["schemaTypeInfo"]=> NULL } [1]=> object(DOMElement)#6 (18) { ["nodeName"]=> string(4) "item" ["nodeValue"]=> string(0) "" ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["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(4) "item" ["baseURI"]=> string(1) "/" ["textContent"]=> string(0) "" ["tagName"]=> string(4) "item" ["schemaTypeInfo"]=> NULL } [2]=> object(DOMElement)#7 (18) { ["nodeName"]=> string(4) "item" ["nodeValue"]=> string(0) "" ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> string(22) "(object value omitted)" ["nextSibling"]=> NULL ["attributes"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(4) "item" ["baseURI"]=> string(1) "/" ["textContent"]=> string(0) "" ["tagName"]=> string(4) "item" ["schemaTypeInfo"]=> NULL } }
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.3.11 - 5.3.29, 5.4.1 - 5.6.28
int(3) array(3) { [0]=> object(DOMElement)#4 (18) { ["tagName"]=> string(4) "item" ["schemaTypeInfo"]=> NULL ["nodeName"]=> string(4) "item" ["nodeValue"]=> string(0) "" ["nodeType"]=> int(1) ["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"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(4) "item" ["baseURI"]=> string(1) "/" ["textContent"]=> string(0) "" } [1]=> object(DOMElement)#5 (18) { ["tagName"]=> string(4) "item" ["schemaTypeInfo"]=> NULL ["nodeName"]=> string(4) "item" ["nodeValue"]=> string(0) "" ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["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(4) "item" ["baseURI"]=> string(1) "/" ["textContent"]=> string(0) "" } [2]=> object(DOMElement)#6 (17) { ["tagName"]=> string(4) "item" ["schemaTypeInfo"]=> NULL ["nodeName"]=> string(4) "item" ["nodeValue"]=> string(0) "" ["nodeType"]=> int(1) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> NULL ["lastChild"]=> NULL ["previousSibling"]=> string(22) "(object value omitted)" ["attributes"]=> string(22) "(object value omitted)" ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(4) "item" ["baseURI"]=> string(1) "/" ["textContent"]=> string(0) "" } }
Output for 5.3.7 - 5.3.10, 5.4.0
int(3) array(3) { [0]=> object(DOMElement)#4 (0) { } [1]=> object(DOMElement)#5 (0) { } [2]=> object(DOMElement)#6 (0) { } }
Output for 5.3.6
int(1) array(1) { [24148384]=> object(DOMElement)#4 (0) { } }
Output for 5.3.5
int(1) array(1) { [47274400]=> object(DOMElement)#4 (0) { } }
Output for 5.3.4
int(1) array(1) { [23427488]=> object(DOMElement)#4 (0) { } }
Output for 5.3.3
int(1) array(1) { [36120992]=> object(DOMElement)#4 (0) { } }
Output for 5.2.0 - 5.3.2
Catchable fatal error: Argument 1 passed to iterator_to_array() must implement interface Traversable, instance of DOMNodeList given in /in/855aX on line 7
Process exited with code 255.
Output for 5.1.0 - 5.1.6
Warning: iterator_to_array() expects parameter 1 to be Traversable, object given in /in/855aX on line 7 int(1) bool(false)
Output for 5.0.0 - 5.0.5
Fatal error: Call to undefined function iterator_to_array() in /in/855aX on line 7
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/855aX on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: domdocument in /in/855aX on line 5