在PHP中通过此JSON代码获取信息

时间:2019-04-10 14:52:54

标签: php json

我在获取Received By详细信息时遇到了麻烦。这是我到目前为止尝试过的:

JSON响应:https://pastebin.com/Uty460UY

$decoder=json_decode($response,true);
foreach($decoder['data']['hits'] as $cltn1){
$caller = $cltn1['_source']['caller_number'];
$pickedby = $cltn1['log_details']['received_by']['name'];

这是公司向我们提供的JSON响应

1 个答案:

答案 0 :(得分:0)

简单的数组var_dump()足以说明问题。无论如何,这是您的答案。

$x = json_decode($json, true);

foreach ($x['data']['hits'] as $key => $val) {
    $receivedBy = $val['_source']['log_details'][0]['received_by'][0];
    var_dump($receivedBy);
}

您可以在这里看到https://3v4l.org/tImqD