note 56991 modified in function.fread by danbrown
| From: | danbrown@php.net | Date: | Fri, 06 Jan 2012 21:10:18 +0000 |
| Subject: | note 56991 modified in function.fread by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-185435@lists.php.net to get a copy of this message | ||
<?php
/*
geoCode($address)
Accepts an address in the form of
999 Geocode Dr. New York, Ny 10108
returns array with lat and lon
*/
function geoCode($address) {
$gaddress = "http://maps.google.com?q="
. urlencode($address);
$handle = fopen($gaddress, "r");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);
ereg('<center lat="([0-9.-]{1,})" lng="([0-9.-]{1,})"/>',
$contents, $regs);
$returnData['lat'] = $regs[1];
$returnData['lon'] = $regs[2];
return $returnData;
}
print_r(geoCode("1064 Georgetown ln. Birmingham, Al 35217"));
?>
--was--
/*
geoCode($address)
Accepts an address in the form of
999 Geocode Dr. New York, Ny 10108
returns array with lat and lon
*/
function geoCode($address) {
$gaddress = "http://maps.google.com?q="
. urlencode($address);
$handle = fopen($gaddress, "r");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);
ereg('<center lat="([0-9.-]{1,})" lng="([0-9.-]{1,})"/>',
$contents, $regs);
$returnData['lat'] = $regs[1];
$returnData['lon'] = $regs[2];
return $returnData;
}
print_r(geoCode("1064 Georgetown ln. Birmingham, Al 35217"));
http://php.net/manual/en/function.fread.php