title: use Google geocode to return street name and list of house numbers using php
body: <p>I have a registration form that I would like to fill with data when a user arrives on this section of the form.
  The first part of the form asks for the postcode/zip code. On the form load I would like to be able to display a list of house numbers with the street name.</p>
  
  <p>This is what I have to return the data</p>
  
  <pre><code>&lt;?php
  $postcode = 'DH90ER';
  $geourl = file_get_contents("http://maps.googleapis.com/maps/api/geocode/json?address=$postcode&amp;sensor=true");
  
  $array = json_decode($geourl,TRUE);
  
  print header("Content-type: text/plain");
  
  print_r($array);
  
  ?&gt;
  </code></pre>
  
  <p>This works it reruns an array of information that i need except the street name or numbers.
  For example if I echo </p>
  
  <pre><code>echo $array['results'][0]['address_components'][1]['long_name'];
  </code></pre>
  
  <p>This would echo the Town name. Its messy I know but it works really well.
  Is there a way I can get a the street name as postal codes are unique to street names and the number of possible houses?</p>
  
  <p>I've been stuck for a while on this, I will use javascript if it is possible with javascript.</p>
  
  <p>UPDATE to return single house number and street name</p>
  
  <pre><code>$geourl = file_get_contents("http://maps.googleapis.com/maps/api/geocode/json?address=$postcode&amp;sensor=true");
  
  $array = json_decode($geourl,TRUE);
  
  print header("Content-type: text/plain");
  
  
  $lat = $array['results'][0]['geometry']['location']['lat'];
  
  $lng = $array['results'][0]['geometry']['location']['lng'];
  
  
  $add = file_get_contents("https://maps.googleapis.com/maps/api/geocode/json?latlng=$lat,$lng");
  
  $add = json_decode($add);
  print_r($add);
  </code></pre>