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); if ($xmlObj !== false) { $xmlArr = objectsIntoArray($xmlObj); var_dump($xmlArr); } function objectsIntoArray($arrObjData, $arrSkipIndices = array()) { $arrData = array(); if ($arrObjData instanceof SimpleXMLElement) { $suggestions = $xml->xpath('/CompleteSuggestion/suggestion/@data'); while(list($test, $node) = each($suggestions)) { echo $test, $node,"\n"; } // $arrObjData = get_object_vars($arrObjData); } if (is_array($arrObjData)) { foreach ($arrObjData as $index => $value) { if (is_object($value) || is_array($value)) { $value = objectsIntoArray($value, $arrSkipIndices); } if (in_array($index, $arrSkipIndices)) { continue; } $arrData[$index] = $value; } } return $arrData; }
Output for 7.0.5 - 7.1.0
Notice: Undefined variable: xml in /in/GfaaY on line 15 Fatal error: Uncaught Error: Call to a member function xpath() on null in /in/GfaaY:15 Stack trace: #0 /in/GfaaY(7): objectsIntoArray(Object(SimpleXMLElement)) #1 {main} thrown in /in/GfaaY on line 15
Process exited with code 255.
Output for 7.0.0 - 7.0.4
Notice: Undefined variable: xml in /in/GfaaY on line 15 Fatal error: Uncaught Error: Call to a member function xpath() on unknown in /in/GfaaY:15 Stack trace: #0 /in/GfaaY(7): objectsIntoArray(Object(SimpleXMLElement)) #1 {main} thrown in /in/GfaaY on line 15
Process exited with code 255.
Output for hhvm-3.12.0
Notice: Undefined variable: xml in /in/GfaaY on line 15 Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function xpath() on a non-object (null)' in /in/GfaaY:15 Stack trace: #0 /in/GfaaY(7): objectsIntoArray() #1 {main}
Process exited with code 255.
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.6.7 - 5.6.28
Notice: Undefined variable: xml in /in/GfaaY on line 15 Fatal error: Call to a member function xpath() on null in /in/GfaaY on line 15
Process exited with code 255.
Output for 5.0.4 - 5.5.35
Notice: Undefined variable: xml in /in/GfaaY on line 15 Fatal error: Call to a member function xpath() on a non-object in /in/GfaaY on line 15
Process exited with code 255.
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: xml in /in/GfaaY on line 15 Fatal error: Call to a member function xpath() on a non-object in /in/GfaaY on line 15
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING in /in/GfaaY on line 14
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING in /in/GfaaY on line 14
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/GfaaY on line 14
Process exited with code 255.