title: Finding towns within a 10 mile radius of postcode. Google maps API
body: <p>I've recently started looking at the Google Maps API to try out something new in my websites. I am currently using this code:</p>
  
  <pre><code>&lt;?php
  
  $postcode = $_REQUEST['postcode'];
  
  $url = 'http://maps.googleapis.com/maps/api/geocode/xml?address='.$postcode.'&amp;sensor=false';
  $parsedXML = simplexml_load_file($url);
  
  if($parsedXML-&gt;status != "OK") {
  echo "There has been a problem: " . $parsedXML-&gt;status;
  }
  
  $myAddress = array();
  foreach($parsedXML-&gt;result-&gt;address_component as $component) {
  if(is_array($component-&gt;type)) $type = (string)$component-&gt;type[0];
  else $type = (string)$component-&gt;type;
  
  $myAddress[$type] = (string)$component-&gt;long_name;
  }
  header('Content-Type: application/json');
  echo json_encode($myAddress);
  
  
  ?&gt;
  </code></pre>
  
  <p>which simply uses a postcode that I define and searches the Google database and then returns the town, county etc.</p>
  
  <p>If possible, I would like to not only show the nearest town but also any within a 5-10 mile radius. Could someone tell me how I would go about doing this please?</p>
  
  <p>Thanks for any help</p>