Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 906021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:19:00+00:00 2026-05-15T16:19:00+00:00

for this json api response I am able to parse with json_decode: $string =

  • 0

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??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T16:19:01+00:00Added an answer on May 15, 2026 at 4:19 pm

    You will need something like:

    foreach($obj->offices as $office) {
        echo $office->address1; // The first would be '1600 Amphitheatre Parkway'
    }
    

    To view contents of your decoded json do something like the following:

    echo "<pre>";
    print_r($obj);
    echo "</pre>";
    

    In your case this would give you:

    stdClass Object
    (
        [offices] => Array
            (
                [0] => stdClass Object
                    (
                        [description] => Google Headquarters
                        [address1] => 1600 Amphitheatre Parkway
                        [address2] => 
                        [zip_code] => 
                        [city] => Mountain View
                        [state_code] => CA
                        [country_code] => USA
                    )
    
            )
    
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I call the Google geolocation service like this: $querystring = http://maps.googleapis.com/maps/api/geocode/json?sensor=false&latlng=.$row['lat'].,.$row['lng']; $context = stream_context_create(array(
I'm using the Google Maps API. Please see this JSON response . The HTML
I am getting json response from this google api service to get reverse geo
I have this JSON http://www.progmic.com/ielts/retrive.php that I need to parse. When I do it
I'm currently parsing a JSON response from the Google Translate API. I'm able to
If I put this URL: http://maps.googleapis.com/maps/api/geocode/json?address=la%20coru%C3%B1a,%20la%20coru%C3%B1a,%20espa%C3%B1a&sensor=false&region=es I get this json object: { results :
This works: $.post( 'http://api.imgur.com/2/upload.json', { key: 'dsfdwerwersf53534dfsfse3', image: 'http://i.imgur.com/UH17u.png' }, function( data ) {
how would i tranfoms this curl command: curl -v -u 82xxxxxxxxxxxx63e6:api_token -X GET https://www.toggl.com/api/v6/time_entries.json
I have written down the following code: var url = http://maps.googleapis.com/maps/api/geocode/json?latlng=+position.coords.latitude+,+position.coords.longitude+&sensor=false&callback=parseMe; console.log('URL is --
This is my code: import play.api.mvc._ import play.api.libs.json._ import play.api.libs.json.Json._ import play.api.libs.json.Writes._ class BaseController

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.