M
M
Maxim2019-06-01 17:24:43
PHP
Maxim, 2019-06-01 17:24:43

How to parse multidimensional json array in php?

Good afternoon, I receive a json array of the following form via rest api.

data {
  calls
    {
    "id": "7e734dc1-544d-4f04-8ccc-8bd5b197a88c",
    "caller": 
    {
        "name": "u2 u2",
        "extension": "101"
    },
    "called": 
    [
        {
            "isConnected": true,
            "name": "akmightycall4 akmightycall4",
            "extension": "100"
        },
        {
            "isConnected": false,
            "name": "u3 u3",
            "extension": "102",
            "phone": "+75551112235"
        }
    ],
    "businessNumber": "+74950152729",
    "dateTimeUtc": "2018-06-05T13:38:29.522Z",
    "duration": "23066",
    "direction": "Outgoing",
    "callStatus": "Connected",
    "callRecord": 
    {
        "fileName": "records/T1U9Y5b197a88c.wav",
           "uri": "http://localhost/u2.wav?recordid=fdaVn2YWttaWdodHljYWxGV20"
    }
}
}

With the help of the following code, I can pull out the values ​​that come after calls of type id:
$json = json_decode($result, true);

foreach($json['data']['calls'] as $item) {
print $item['id'];
print '<br>';
}

But I don't understand how I can get values ​​from called and caller. Explain, please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey, 2019-06-01
@VladimirAndreev

var_dump($item)...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question