title: PHP: How do I get an attribute from a JSON array?
body: <p>I have the following JSON array:</p>
  
  <pre><code>&lt;?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
          }
        }
      }
    } ]
  };
  ?&gt;
  </code></pre>
  
  <p>Using PHP, how do I get the <code>geometery-&gt;location-&gt;lat</code>&amp;<code>lng</code> values from my JSON array above?</p>
  
  <p>For example (pseudo code):</p>
  
  <pre><code>&lt;?php
  $lat = $json['geometry']['location']['lat'];  // 41.9858860
  $lng = $json['geometry']['location']['lng'];  // -87.7907460
  ?&gt;
  </code></pre>