php - JSON not showing responnse -
the following code not work me.
<?php $json_string = file_get_contents("http://api.wunderground.com/api/7ec5f6510a4656df/geolookup/forecast/q/40121 .json"); $parsed_json = json_decode($json_string); $temp = $parsed_json->{'forecast'}->{'date'}; echo "current date ${temp}\n"; ?>
it works when put so:
$temp = $parsed_json->{'location'}->{'city'};
what missing here lol
it should be:
$temp = $parsed_json->{'forecast'}->{'txt_forecast'}->{'date'};
for better way of viewing json objects, @ this site.
Comments
Post a Comment