for this json api response I am able to parse with json_decode:
$string = '{"name": "Google",
"permalink": "google",
"homepage_url": "http://google.com",
"blog_url": "http://googleblog.blogspot.com",
"blog_feed_url": "http://googleblog.blogspot.com/feeds/posts/default?alt=rss",
"twitter_username": "google",
"category_code": "search",
"number_of_employees": 20000,
"founded_year": 1998,
"founded_month": 9,
"founded_day": 7,// bla bla.....}';
$obj=json_decode($string);
echo $obj->number_of_employees."<br>";// 20000
echo $obj->founded_year; //1998
I am getting result with above but getting blank result with below one:
$string = '{"offices":
[{"description": "Google Headquarters",
"address1": "1600 Amphitheatre Parkway",
"address2": "",
"zip_code": "",
"city": "Mountain View",
"state_code": "CA",
"country_code": "USA",//blah blah }]//blah blah...}';
$obj=json_decode($string);
echo $obj->address1."<br>";// ""
echo $obj->city; //""
I am aware that address1 is again inside another array or loop but dont know how to retrieve it...any ideas??