I am trying to parse the data from the following json
{
"id":"1",
"rawId":"1",
"displayName":"Distress Number",
"name":{"familyName":"Number","formatted":"Distress Number","givenName":"Distress"},
"nickname":null,
"phoneNumbers":[{"type":"other","value":"112","id":"2","pref":false}],
"emails":[{"type":"other","value":"[email protected]","id":"19","pref":false}],
"addresses":null,
"ims":null,"organizations":null,
"birthday":null,
"note":"","photos":null,
"categories":null,
"urls":null
}
I want to insert the displaName,phoneNumbers and emails to database table but its failed
Here is my php
$contact=json_decode($json,true){
foreach($contact as $con){
$num=$con['phoneNumbers']['value'];
$name=$con['displayName'];
$email=$con['emails']['value'];
//function to dbinsert
insertToDb($num,$name,$email);
}
But it returns illegal offset warning