3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $json = <<<EOD {"info":{"orderid":"166","order_code":"7b601857-af5a-4487-865d-21683ae5dd6b","pay_summ":"70.58","comiss":"4.76","total_summ":"75.34","segment":{"ticket":"\u042362-\u04151-5291440-0608","creation_time":"06.08.2013 15:55:52","num":"1","tot_price":"06.08.2013 15:55:52","tax":"06.08.2013 15:55:52","transporte_type":"2","places":[{"car_num":"04","car_type":"1020","loc_num":"02"}]}},"data":{"version":"1.0.0","orderid":"166","merrespurl":"http:\/\/tickets.nikita.dev\/ecommerce\/liqpay","merid":"I0110DQX","acqid":"414963","purchaseamt":"000000007534","purchasecurrencyexponent":2,"purchasecurrency":"980","orderdescription":"Ticket purchase from http:\/\/privatbank.ua\/","signature":"MAfxoGuJ2FY8GIPdfES1k\/55IBU="},"condition":"9869626e88933abb30fe5d7bd317e826","status":"yes"} EOD; class Helper { function objectToArray($d) { if (is_object($d)) { // Gets the properties of the given object // with get_object_vars function $d = get_object_vars($d); } if (is_array($d)) { /* * Return array converted to object * Using __FUNCTION__ (Magic constant) * for recursive call */ return array_map(__METHOD__, $d); } else { // Return array return $d; } } } $helper = new Helper; var_dump($helper->objectToArray(json_decode($json)));
Output for 5.3.0 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
array(4) { ["info"]=> array(6) { ["orderid"]=> string(3) "166" ["order_code"]=> string(36) "7b601857-af5a-4487-865d-21683ae5dd6b" ["pay_summ"]=> string(5) "70.58" ["comiss"]=> string(4) "4.76" ["total_summ"]=> string(5) "75.34" ["segment"]=> array(7) { ["ticket"]=> string(21) "У62-Е1-5291440-0608" ["creation_time"]=> string(19) "06.08.2013 15:55:52" ["num"]=> string(1) "1" ["tot_price"]=> string(19) "06.08.2013 15:55:52" ["tax"]=> string(19) "06.08.2013 15:55:52" ["transporte_type"]=> string(1) "2" ["places"]=> array(1) { [0]=> array(3) { ["car_num"]=> string(2) "04" ["car_type"]=> string(4) "1020" ["loc_num"]=> string(2) "02" } } } } ["data"]=> array(10) { ["version"]=> string(5) "1.0.0" ["orderid"]=> string(3) "166" ["merrespurl"]=> string(42) "http://tickets.nikita.dev/ecommerce/liqpay" ["merid"]=> string(8) "I0110DQX" ["acqid"]=> string(6) "414963" ["purchaseamt"]=> string(12) "000000007534" ["purchasecurrencyexponent"]=> int(2) ["purchasecurrency"]=> string(3) "980" ["orderdescription"]=> string(42) "Ticket purchase from http://privatbank.ua/" ["signature"]=> string(28) "MAfxoGuJ2FY8GIPdfES1k/55IBU=" } ["condition"]=> string(32) "9869626e88933abb30fe5d7bd317e826" ["status"]=> string(3) "yes" }
Output for 5.2.0 - 5.2.17
Warning: array_map(): The first argument, 'Helper::objectToArray', should be either NULL or a valid callback in /in/p1a8U on line 19 NULL
Output for 5.0.0 - 5.1.1, 5.1.3 - 5.1.6
Fatal error: Call to undefined function json_decode() in /in/p1a8U on line 28
Process exited with code 255.
Output for 5.1.2
Fatal error: Call to undefined function json_decode() in /in/p1a8U on line 29
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: json_decode() in /in/p1a8U on line 28
Process exited with code 255.
Output for 4.3.2 - 4.4.1, 4.4.3 - 4.4.4
Fatal error: Call to undefined function: json_decode() in /in/p1a8U on line 28
Process exited with code 255.
Output for 4.4.2
Fatal error: Call to undefined function: json_decode() in /in/p1a8U on line 29
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: json_decode() in /in/p1a8U on line 28