PHP Json array in array -
i want catch code=10720 in php .but can't.thanks.
{ "orderid":"6597943", "extorderid":"extorderid0", "merchantposid":"kampushg", "status":{ "statuscode":"openpayu_error_value_invalid", "code":"10720", "codeliteral":"transaction_invalid_params", "location":"installmentpayment", "statusdesc":["invalid_card_no","invalid_card_expiration_date","invalid_card_cvv"] } }
$json = '{ "orderid":"6597943", "extorderid":"extorderid0", "merchantposid":"kampushg", "status":{ "statuscode":"openpayu_error_value_invalid", "code":"10720", "codeliteral":"transaction_invalid_params", "location":"installmentpayment", "statusdesc":["invalid_card_no"] } }'; $ar = json_decode($json,true); # json-string array # php version < 7 $code = isset($ar['status']['code'])?$ar['status']['code']:'default value'; # php version >= 7 $code = isset($ar['status']['code'])??'default value';
Comments
Post a Comment