views:

449

answers:

2

I know this is possible in Javascript but I need to do it using only PHP, how can I?

+4  A: 

Yes, there's a HTTP geocoding interface that you can call from any server language.

Mike Williams
+1 for agreement.
thephpdeveloper
Perfect! Thanks.
Andrew G. Johnson
+2  A: 

Using Google Map API and PHP to get coordinates:

$url = 'http://maps.google.com/maps/geo?q='.$address.'&output=json&oe=utf8&sensor=false&key='.$api_key;
$data = @file_get_contents($url);
$jsondata = json_decode($data,true);
if(is_array($jsondata )&& $jsondata ['Status']['code']==200){
  $lat = $jsondata ['Placemark'][0]['Point']['coordinates'][0];
  $lon = $jsondata ['Placemark'][0]['Point']['coordinates'][1];
}
thephpdeveloper