I have this JSON string:
$json= '{"data":[{"id":"123","name":"john smith","gender":"MALE","phone":[{"number":"+919999999999","numberType":"MOBILE"}]}]}'
I want to retrieve all the values and keys from the json, output should look like:
id: 123
name: john smith
gender: MALE
phone:
number: +919999999999
numberType: MOBILE
I have tried this code but it fails to get the phone output:
$jsond = json_decode($json);
foreach($jsond->data as $row)
{
foreach($row as $key => $val)
{
echo $key . ': ' . $val;
}
}