I'm trying to parse the json response from the Google Geocode API but I'm having a little trouble understanding it.
For those unfamiliar with the Geocode API here is the URL: http://maps.google.com/maps/api/geocode/json?address=albert%20square&sensor=false
I'm using the following code to parse the request
<?php
$address = urlencode($_POST['address']);
$request = file_get_contents("http://maps.google.com/maps/api/geocode/json?address=" . $address . "&sensor=false");
$json = json_decode($request, true);
?>
And I'm trying to output with the following:
echo $json['results'][0]['formated_address'];
I'm not sure why nothing is being echoed. I've also tried $json[0]['results'][0]['formated_address']
. I know this is a noob question, but multi-dimensional arrays confuse me.
echo $json['results'][0]['formatted_address'];
It helps if you spell it correctly ;-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With