3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $xml = '<items><item/><item/><item/><foo:bar xmlns:foo="urn:foo"/></items>'; $dom = new DOMDocument(); $dom->loadXml($xml); $xpath = new DOMXpath($dom); $array = iterator_to_array($xpath->evaluate('//*')); var_dump(count($array), array_keys($array));
Output for 5.3.7 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
int(5) array(5) { [0]=> int(0) [1]=> int(1) [2]=> int(2) [3]=> int(3) [4]=> int(4) }
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.3.3 - 5.3.6
int(1) array(1) { [0]=> int(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/3YJqf on line 9
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/3YJqf on line 9 Warning: array_keys(): The first argument should be an array in /in/3YJqf on line 11 int(1) NULL
Output for 5.0.0 - 5.0.5
Fatal error: Call to undefined function iterator_to_array() in /in/3YJqf on line 9
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/3YJqf 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/3YJqf on line 5