我是 php 新手。我试图从 json 对象获取值。我尝试了很多次,但未能从 json 中获取价值。我只需要 json 数组中的“txnToken”。我的代码是
$json = json_decode($data, true);
foreach ($json as $key => $value) {
foreach ($value as $key1 => $value1) {
print_r($key1);
}
}
JSON 响应是:
{
"head": {
"responseTimestamp":"1596640639585",
"version":"v1",
"clientId":"WEB",
"signature":"xxxxxxxxxxxxxxxx"
},
"body":{
"resultInfo":{
"resultStatus":"S",
"resultCode":"0000",
"resultMsg":"Success"
},
"txnToken":"xxxxxxxxxxxxx",
"isPromoCodeValid":false,
"authenticated":false
}
}
提前致谢。
元芳怎么了
慕斯709654