3v4l.org

run code in 300+ PHP versions simultaneously
<?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(get_object_vars($xmlObj));
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Deprecated: Function utf8_encode() is deprecated in /in/aQ2Wi on line 4 array(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" } } } } }
Output for 5.3.0 - 5.3.29, 5.5.27 - 5.5.38, 5.6.11 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
array(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" } } } } }
Output for 5.4.28 - 5.4.45, 5.5.12 - 5.5.26, 5.6.0 - 5.6.10
array(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" } } } } }
Output for 5.4.0 - 5.4.27, 5.5.0 - 5.5.11
array(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" } } } } }
Output for 5.1.2 - 5.1.6, 5.2.0 - 5.2.17
array(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" } } } } }
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.1
array(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) { } } } }
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: simplexml_load_string() in /in/aQ2Wi on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Fatal error: Call to undefined function: simplexml_load_string() in /in/aQ2Wi 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/aQ2Wi on line 4

preferences:
259.53 ms | 401 KiB | 356 Q