我是 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 }}提前致謝。
- 2 回答
- 0 關注
- 144 瀏覽
添加回答
舉報
0/150
提交
取消