I am new to php. I trying to get value from json object. I tried many time but i failed to get value from json. I need only "txnToken" from json array. My code is
$json = json_decode($data, true);
foreach ($json as $key => $value) {
foreach ($value as $key1 => $value1) {
print_r($key1);
}
}
And JSON Response is:
{
"head": {
"responseTimestamp":"1596640639585",
"version":"v1",
"clientId":"WEB",
"signature":"xxxxxxxxxxxxxxxx"
},
"body":{
"resultInfo":{
"resultStatus":"S",
"resultCode":"0000",
"resultMsg":"Success"
},
"txnToken":"xxxxxxxxxxxxx",
"isPromoCodeValid":false,
"authenticated":false
}
}
Thanks in advance.