3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); global $n; $n=0; 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, $z=0) { foreach (array_keys((array)$simpleXmlObj) as $key => $element) { $el = (array)$simpleXmlObj->$element; if(isset($el[0])){ print_r($el[0]); $trim = trim($el[0]); echo '>>>';print_r($trim);echo '<<<'; if (empty($trim) && $trim !== 0) { unset($simpleXmlObj->$element); } }else{ $simpleXmlObj->$element = _fixEmptyStringDifference($simpleXmlObj->$element, $z+1); } } 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
true>>>true<<<SimpleXMLElement Object ( ) >>><<<21/09/2015 03:26:37>>>21/09/2015 03:26:37<<<Array ( [SUCCESS] => true [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:
64.67 ms | 401 KiB | 8 Q