php know if city exist gmap api

Solutions on MaxInterview for php know if city exist gmap api by the best coders in the world

showing results for - "php know if city exist gmap api"
Angela
25 Jan 2019
1   public static function  latlong($location) {
2
3        if ($location!='') {
4            try {
5                $json = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address='.urlencode($location));
6                $parsedjson = json_decode($json, true);
7
8                if (key_exists(0,$parsedjson['results'])) {
9                    $lat_long_array = $parsedjson['results'][0]['geometry']['location'];
10                    return $lat_long_array;
11                } else {
12                    return false;
13                }
14            } catch (Exception $e) {
15                //echo 'Caught exception: ',  $e->getMessage(), "\n";
16                return false;
17            }
18        }
19
20
21    }
22