<?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;
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(__FUNCTION__, $d);
}
else {
// Return array
return $d;
}
}
var_dump(objectToArray(json_decode($json)));
- Output for 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- 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.0.0 - 5.0.5, 5.1.0 - 5.1.1, 5.1.3 - 5.1.6
- Fatal error: Call to undefined function json_decode() in /in/qS9fB on line 25
Process exited with code 255. - Output for 5.1.2
- Fatal error: Call to undefined function json_decode() in /in/qS9fB on line 26
Process exited with code 255. - Output for 4.4.5 - 4.4.9
- Fatal error: Call to undefined function: json_decode() in /in/qS9fB on line 25
Process exited with code 255. - Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.1, 4.4.3 - 4.4.4
- Fatal error: Call to undefined function: json_decode() in /in/qS9fB on line 25
Process exited with code 255. - Output for 4.4.2
- Fatal error: Call to undefined function: json_decode() in /in/qS9fB on line 26
Process exited with code 255. - Output for 4.3.0 - 4.3.1
- Fatal error: Call to undefined function: json_decode() in /in/qS9fB on line 25
preferences:
304.3 ms | 401 KiB | 457 Q