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 924165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:18:12+00:00 2026-05-15T19:18:12+00:00

I have the following JSON array: <?php $json = { status: OK, results: [

  • 0

I have the following JSON array:

<?php    
$json = {
  "status": "OK",
  "results": [ {
    "types": [ "street_address" ],
    "formatted_address": "5721 N Northcott Ave, Chicago, IL 60631, USA",
    "address_components": [ {
      "long_name": "5721",
      "short_name": "5721",
      "types": [ "street_number" ]
    }, {
      "long_name": "Illinois",
      "short_name": "IL",
      "types": [ "administrative_area_level_1", "political" ]
    }, {
      "long_name": "60631",
      "short_name": "60631",
      "types": [ "postal_code" ]
    } ],
    "geometry": {
      "location": {
        "lat": 41.9858860,
        "lng": -87.7907460
      },
      "location_type": "ROOFTOP",
      "viewport": {
        "southwest": {
          "lat": 41.9827384,
          "lng": -87.7938936
        },
        "northeast": {
          "lat": 41.9890336,
          "lng": -87.7875984
        }
      }
    }
  } ]
};
?>

Using PHP, how do I get the geometery->location->lat&lng values from my JSON array above?

For example (pseudo code):

<?php
$lat = $json['geometry']['location']['lat'];  // 41.9858860
$lng = $json['geometry']['location']['lng'];  // -87.7907460
?>
  • 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-15T19:18:13+00:00Added an answer on May 15, 2026 at 7:18 pm

    You use json_decode and then $var->results[0]->geometry->location->lat;.

    json_decode yields the following structure:

    object(stdClass)[1]
      public 'status' => string 'OK' (length=2)
      public 'results' => 
        array
          0 => 
            object(stdClass)[2]
              public 'types' => 
                array
                  0 => string 'street_address' (length=14)
              public 'formatted_address' => string '5721 N Northcott Ave, Chicago, IL 60631, USA' (length=44)
              public 'address_components' => 
                array
                  0 => 
                    object(stdClass)[3]
                      public 'long_name' => string '5721' (length=4)
                      public 'short_name' => string '5721' (length=4)
                      public 'types' => 
                        array
                          0 => string 'street_number' (length=13)
                  1 => 
                    object(stdClass)[4]
                      public 'long_name' => string 'Illinois' (length=8)
                      public 'short_name' => string 'IL' (length=2)
                      public 'types' => 
                        array
                          0 => string 'administrative_area_level_1' (length=27)
                          1 => string 'political' (length=9)
                  2 => 
                    object(stdClass)[5]
                      public 'long_name' => string '60631' (length=5)
                      public 'short_name' => string '60631' (length=5)
                      public 'types' => 
                        array
                          0 => string 'postal_code' (length=11)
              public 'geometry' => 
                object(stdClass)[6]
                  public 'location' => 
                    object(stdClass)[7]
                      public 'lat' => float 41.985886
                      public 'lng' => float -87.790746
                  public 'location_type' => string 'ROOFTOP' (length=7)
                  public 'viewport' => 
                    object(stdClass)[8]
                      public 'southwest' => 
                        object(stdClass)[9]
                          public 'lat' => float 41.9827384
                          public 'lng' => float -87.7938936
                      public 'northeast' => 
                        object(stdClass)[10]
                          public 'lat' => float 41.9890336
                          public 'lng' => float -87.7875984
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code which encodes json in php $arr = array('htmlOutput' =>
I have the following JSON object: { response: { status: 200 }, messages: [
i have following json format { status: ACTIVE, result: false, isworking: false, margin: 1,
I have a php query the returns the following JSON format from a table.
I have a php query the returns the following JSON format from a table.
I have the following JSON string, which was an Objective C array then encoded
I have the following PHP that creates some JSON from a MySQL query. This
I have the following php: 1) echo json_encode(array('message' => 'Invalid Login Details: '.$user)); I
I have the following PHP array: array(Apple, Pear, Grape, Orange) And I'd like to
I have the following PHP and JS: <?php // Here's where the array of

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.