Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $jsonurl = "http://maps.googleapis.com/maps/api/geocode/json?address=$zip&sensor=false";
- $json = file_get_contents($jsonurl,0,null,null);
- $json_output = json_decode($json, true);
- for ($i = 0; $i < 5; $i++) {
- if ($json_output['results'][0]['address_components'][$i]['types'][0] == 'administrative_area_level_1') {
- return $json_output['results'][0]['address_components'][$i]['short_name'];
- }
- }
- return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement