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

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -