title: Google Reverse-Geocode - Get ZIP code
body: <p>Here is my current code on how I'm getting different components.</p>
  
  <pre><code>function getGeocodeFull($address)
  {
      if (empty($address)) return false;
  
      $_geocode = false; 
  
      if (($_geocode = $this-&gt;getCache($address)) === false) // check if address is has a cache
      {
          if (($results = $this-&gt;geoGetCoordsFull($address)) !== false) 
          {
              // sloooooooooopppy.. yes these can all be combined, i know.
              if (!isset($results-&gt;results[0]-&gt;geometry-&gt;location-&gt;lat))  return false;
              if (!isset($results-&gt;results[0]-&gt;geometry-&gt;location-&gt;lat))  return false;
              if (!isset($results-&gt;results[0]-&gt;formatted_address))        return false;
              if (!isset($results-&gt;results[0]-&gt;address_components))       return false;
  
              $_geocode['lat']     = $results-&gt;results[0]-&gt;geometry-&gt;location-&gt;lat;
              $_geocode['lon']     = $results-&gt;results[0]-&gt;geometry-&gt;location-&gt;lng;
              $_geocode['address'] = $results-&gt;results[0]-&gt;formatted_address;
  
              foreach ($results-&gt;results[0]-&gt;address_components as $component)
              {
                  if (isset($component-&gt;types))
                  {
                      foreach ($component-&gt;types as $type)
                      {
                          switch ($type)
                          {
                              case 'route':
                                  $_geocode['street'] = $component-&gt;long_name;
                                  break;
                              case 'locality':
                                  $_geocode['city'] = $component-&gt;long_name;
                                  break;
                              case 'administrative_area_level_2':
                                  $_geocode['county'] = $component-&gt;long_name;
                                  break;
                              case 'administrative_area_level_3':
                                  $_geocode['area'] = $component-&gt;long_name;
                                  break;
                              case 'postal_code':
                                  $_geocode['zip'] = $component-&gt;short_name;
                                  break;
                          }     
                      }
                  }    
              }
  
              $this-&gt;putCacheFull($address, $_geocode['lat'], $_geocode['lon'], $_geocode['address'], $_geocode['street'], $_geocode['city'], $_geocode['county'], $_geocode['area'], $_geocode['zip']);
          }
      }
  
      return $_geocode;
  }
  </code></pre>
  
  <p>geoGetCoordsFull() simply uses file_get_contents on the google map api geocode page, then decodes the results then returns them.</p>
  
  <p>I'm not too big of a fan of what that looks like.  It seems like it can be very inconsistent.  Are there any other BETTER solutions to getting all the data from google or any other service?</p>
  
  <p>I'd prefer another service that doesn't limit requests (or is it illegal to use multiple geocode services such as bing/yahoo/etc) ?? (sorry for throwing in another question)</p>
  
  <p>Anyway, much help would be very appreciated!</p>