How can i retrieve a particular data from a content obtained using file_get_contents() function in PHP?

For example my code is
” $result = file_get_contents(“http://maps.googleapis.com/maps/api/geocode/json?address=”.$stateName.”,”.$districtName.”,”.$cityName.”&sensor=true”);”
where $stateName, $districtName, $cityName are the values given by the user
After entering Kerala, Ernakulam, Angamaly as the stateName, districtName and cityName i got a result like this:
{ “results” : [ { "address_components" : [ { "long_name" : "Angamaly", "short_name" : "Angamaly", "types" : [ "locality", "political" ] }, { “long_name” : “Ernakulam”, “short_name” : “Ernakulam”, “types” : [ "administrative_area_level_2", "political" ] }, { “long_name” : “Kerala State”, “short_name” : “Kerala State”, “types” : [ "administrative_area_level_1", "political" ] }, { “long_name” : “India”, “short_name” : “IN”, “types” : [ "country", "political" ] } ], “formatted_address” : “Angamaly, Kerala State, India”, “geometry” : { “bounds” : { “northeast” : { “lat” : 10.24647040, “lng” : 76.39544959999999 }, “southwest” : { “lat” : 10.15853350, “lng” : 76.35004510 } }, “location” : { “lat” : 10.2128940, “lng” : 76.3806010 }, “location_type” : “APPROXIMATE”, “viewport” : { “northeast” : { “lat” : 10.24647040, “lng” : 76.39544959999999 }, “southwest” : { “lat” : 10.15853350, “lng” : 76.35004510 } } }, “types” : [ "locality", "political" ] } ], “status” : “OK” }
I need the latitude and longitude of the place…How can I retrieve the ‘lat’ and ‘lng’ from “geometry->bounds->northeast”?

Leave a Reply

*

Hire Me
Follow Me!
Search
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.
Categories