Latitude and Longitude of a location using PHP and Google

The following PHP code will help you acquire the latitude and longitude of a location (using an address, zip code, or city).

Note: Your will be required to have your own domain specific Google API key.

if ($_POST['address']) {
$key = ' '; //you will need yo use your own domain specific API key
$address = stripslashes($_POST['address']);
$addressurl = urlencode($address);
$location = file("".$addressurl."&output=csv&key=".$key);
list ($stat,$acc,$lat,$lng) = explode(",",$location[0]);
echo "LAT:".$lat." - LNG:".$lng;

Below is the HTML code which used a form to submit the address to the above PHP.

<form action="<?php echo $_SERVER['PHP_SELF']; ?>;" method="post">
<input name="address" type="text" />
<input type="submit" value="Submit" />