public function getLatLongForLocation($location)
    {
        $encoded = urlencode($location);
        $response = json_decode(
            file_get_contents("http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=$encoded"),
            true
        );

        if ($response['status'] === 'OK') {
            $lat = $response['results'][0]['geometry']['location']['lat'];
            $long = $response['results'][0]['geometry']['location']['lng'];

            return array($lat, $long);
        }

        return false;
    }
public function getLatLongForLocation($location)
    {
        $encoded = urlencode($location);
        $response = json_decode(
            file_get_contents("http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=$encoded"),
            true
        );

        if ($response['status'] === 'OK') {
            $lat = $response['results'][0]['geometry']['location']['lat'];
            $long = $response['results'][0]['geometry']['location']['lng'];

            return array($lat, $long);
        }

        return false;
    }
public function getLatLongForLocation ( $ location ) { $ encoded = urlencode ( $ location ) ; $ response = json_decode ( file_get_contents ( "http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=$encoded" ) , true ) ; if ( $ response [ 'status' ] === 'OK' ) { $ lat = $ response [ 'results' ] [ 0 ] [ 'geometry' ] [ 'location' ] [ 'lat' ] ; $ long = $ response [ 'results' ] [ 0 ] [ 'geometry' ] [ 'location' ] [ 'lng' ] ; return array ( $ lat , $ long ) ; } return false ; }
This method uses the Google Maps Geocoding API to retrieve the
lat and long for the given location.

More info here: https://developers.google.com/maps/documentation/geocoding/

@param string $location The location to look up the lat/long for

@return array An array of 2 elements: the lat and the long
This method uses the Google Maps Geocoding API to retrieve the lat and long for the given location .