3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $xmlStr = '<?xml version="1.0"?><toplevel><CompleteSuggestion><suggestion data="ski360"/></CompleteSuggestion><CompleteSuggestion><suggestion data="ski 39"/></CompleteSuggestion><CompleteSuggestion><suggestion data="ski35"/></CompleteSuggestion><CompleteSuggestion><suggestion data="ski 3000"/></CompleteSuggestion><CompleteSuggestion><suggestion data="ski 33"/></CompleteSuggestion><CompleteSuggestion><suggestion data="ski 34"/></CompleteSuggestion></toplevel>'; $xmlObj = simplexml_load_string(utf8_encode($xmlStr)); var_dump($xmlObj); $xmlArr = objectsIntoArray($xmlObj); var_dump($xmlArr); function objectsIntoArray($arrObjData, $arrSkipIndices = array()) { $arrData = array(); if (is_object($arrObjData)) { $arrObjData = get_object_vars($arrObjData); } return $arrData; }
Output for 5.3.0 - 5.3.29, 5.5.27 - 5.5.38, 5.6.11 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
object(SimpleXMLElement)#1 (1) { ["CompleteSuggestion"]=> array(6) { [0]=> object(SimpleXMLElement)#2 (1) { ["suggestion"]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(1) { ["data"]=> string(6) "ski360" } } } [1]=> object(SimpleXMLElement)#3 (1) { ["suggestion"]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(1) { ["data"]=> string(6) "ski 39" } } } [2]=> object(SimpleXMLElement)#4 (1) { ["suggestion"]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(1) { ["data"]=> string(5) "ski35" } } } [3]=> object(SimpleXMLElement)#5 (1) { ["suggestion"]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(1) { ["data"]=> string(8) "ski 3000" } } } [4]=> object(SimpleXMLElement)#6 (1) { ["suggestion"]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(1) { ["data"]=> string(6) "ski 33" } } } [5]=> object(SimpleXMLElement)#7 (1) { ["suggestion"]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(1) { ["data"]=> string(6) "ski 34" } } } } } array(0) { }
Output for 5.4.0 - 5.4.27, 5.5.0 - 5.5.11, hhvm-3.10.0
object(SimpleXMLElement)#1 (1) { ["CompleteSuggestion"]=> array(6) { [0]=> object(SimpleXMLElement)#2 (1) { [0]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(1) { ["data"]=> string(6) "ski360" } } } [1]=> object(SimpleXMLElement)#3 (1) { [0]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(1) { ["data"]=> string(6) "ski 39" } } } [2]=> object(SimpleXMLElement)#4 (1) { [0]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(1) { ["data"]=> string(5) "ski35" } } } [3]=> object(SimpleXMLElement)#5 (1) { [0]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(1) { ["data"]=> string(8) "ski 3000" } } } [4]=> object(SimpleXMLElement)#6 (1) { [0]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(1) { ["data"]=> string(6) "ski 33" } } } [5]=> object(SimpleXMLElement)#7 (1) { [0]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(1) { ["data"]=> string(6) "ski 34" } } } } } array(0) { }
Output for 5.4.28 - 5.4.45, 5.5.12 - 5.5.26, 5.6.0 - 5.6.10
object(SimpleXMLElement)#1 (1) { ["CompleteSuggestion"]=> array(6) { [0]=> object(SimpleXMLElement)#2 (1) { [0]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(1) { ["data"]=> string(6) "ski360" } } } [1]=> object(SimpleXMLElement)#3 (1) { [0]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(1) { ["data"]=> string(6) "ski 39" } } } [2]=> object(SimpleXMLElement)#4 (1) { [0]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(1) { ["data"]=> string(5) "ski35" } } } [3]=> object(SimpleXMLElement)#5 (1) { [0]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(1) { ["data"]=> string(8) "ski 3000" } } } [4]=> object(SimpleXMLElement)#6 (1) { [0]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(1) { ["data"]=> string(6) "ski 33" } } } [5]=> object(SimpleXMLElement)#7 (1) { ["suggestion"]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(1) { ["data"]=> string(6) "ski 34" } } } } } array(0) { }
Output for 5.1.2 - 5.2.17
object(SimpleXMLElement)#1 (1) { ["CompleteSuggestion"]=> array(6) { [0]=> object(SimpleXMLElement)#2 (1) { ["suggestion"]=> object(SimpleXMLElement)#8 (1) { ["@attributes"]=> array(1) { ["data"]=> string(6) "ski360" } } } [1]=> object(SimpleXMLElement)#3 (1) { ["suggestion"]=> object(SimpleXMLElement)#9 (1) { ["@attributes"]=> array(1) { ["data"]=> string(6) "ski 39" } } } [2]=> object(SimpleXMLElement)#4 (1) { ["suggestion"]=> object(SimpleXMLElement)#10 (1) { ["@attributes"]=> array(1) { ["data"]=> string(5) "ski35" } } } [3]=> object(SimpleXMLElement)#5 (1) { ["suggestion"]=> object(SimpleXMLElement)#11 (1) { ["@attributes"]=> array(1) { ["data"]=> string(8) "ski 3000" } } } [4]=> object(SimpleXMLElement)#6 (1) { ["suggestion"]=> object(SimpleXMLElement)#12 (1) { ["@attributes"]=> array(1) { ["data"]=> string(6) "ski 33" } } } [5]=> object(SimpleXMLElement)#7 (1) { ["suggestion"]=> object(SimpleXMLElement)#13 (1) { ["@attributes"]=> array(1) { ["data"]=> string(6) "ski 34" } } } } } array(0) { }
Output for 5.0.0 - 5.1.1
object(SimpleXMLElement)#1 (1) { ["CompleteSuggestion"]=> array(6) { [0]=> object(SimpleXMLElement)#2 (1) { ["suggestion"]=> object(SimpleXMLElement)#8 (0) { } } [1]=> object(SimpleXMLElement)#3 (1) { ["suggestion"]=> object(SimpleXMLElement)#9 (0) { } } [2]=> object(SimpleXMLElement)#4 (1) { ["suggestion"]=> object(SimpleXMLElement)#10 (0) { } } [3]=> object(SimpleXMLElement)#5 (1) { ["suggestion"]=> object(SimpleXMLElement)#11 (0) { } } [4]=> object(SimpleXMLElement)#6 (1) { ["suggestion"]=> object(SimpleXMLElement)#12 (0) { } } [5]=> object(SimpleXMLElement)#7 (1) { ["suggestion"]=> object(SimpleXMLElement)#13 (0) { } } } } array(0) { }
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: simplexml_load_string() in /in/nbqO7 on line 4
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: simplexml_load_string() in /in/nbqO7 on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: simplexml_load_string() in /in/nbqO7 on line 4