3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convert($xml) { $simpleXmlObj = simplexml_load_string($xml); $simpleXmlObj = _fixVersionDifferences($simpleXmlObj); $array = _simpleXmlObj2Array($simpleXmlObj); return $array; } function _fixVersionDifferences($simpleXmlObj) { $simpleXmlObj = _fixEmptyStringDifference($simpleXmlObj); return $simpleXmlObj; } function _fixEmptyStringDifference($simpleXmlObj) { foreach (get_object_vars($simpleXmlObj) as $key => $element) { if ($element instanceof \SimpleXMLElement) { $simpleXmlObj->$key = _fixEmptyStringDifference($element); } if ($element != 0 && empty($element)) { unset($simpleXmlObj->$key); } } return $simpleXmlObj; } function _simpleXmlObj2Array($simpleXmlObj) { //Maybe it is not fast but the easiest way to convert return json_decode(json_encode($simpleXmlObj), TRUE); } $xml = <<<xml <?xml version="1.0" encoding="utf-8"?> <RESPONSE> <SUCCESS>true</SUCCESS> <ERRORMESSAGE> </ERRORMESSAGE> <TIMESTAMP>21/09/2015 03:26:37</TIMESTAMP> </RESPONSE> xml; $response = convert($xml); print_r($response);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [SUCCESS] => true [ERRORMESSAGE] => Array ( ) [TIMESTAMP] => 21/09/2015 03:26:37 )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
67.43 ms | 401 KiB | 8 Q