I am trying to figure out how to parse a json response that has multiple results. Here is the response data -
Array
(
[id] => 7181676
[api_request_id] => 20984853
[user] => 8305
[vin] => JTDKN3DU7D1643423
[make] => Toyota
[model_name] => Prius
[model_year] => 2013
[last_updated] => 2019-02-22T01:08:15.628318Z
[recall_count] => 2
[status] => ok
[recalls] => Array
(
[0] => Array
(
[recall_id] => 15753
[recall_age] => 0
[nhtsa_id] => 18V684000
)
[1] => Array
(
[recall_id] => 16733
[recall_age] => 1
[nhtsa_id] => 16V684123
)
)
)
I would like to loop through to get the recalls[0] and recalls[1] as I wont know how many results there will be so cant do it manually.
The response I am looking for is -
2013 Toyota Prius
Recall ID - 1573
Recall Age - 0
Nhtsa Id - 18v684000
Recall ID - 16733
Recall Age - 1
Nhtsa Id - 16v684123
Would I do something like this? -
$data = curl_exec($ch);
$responseData = json_decode($data, TRUE);
foreach($responseData as $item){
echo $item;
}
echo $item['id'];to get it's corresponding value which is7181676