Jump to content

beginner help with php json array


jeremyfarrell

Recommended Posts

i am brand new to php and thought a project looking at the weather undergound api would be a great place to "cut my teeth" and i am following up on a recent post i saw here http://www.phpfreaks.com/forums/index.php?topic=354658.msg1675207#msg1675207

the responder excellently described how to use the foreach function however i am not sure this is right for my application

 

the project i am trying to accomplish is defining the freeze thaw cycle for the next ten days which i can accomplish in excel but thought this is a good way to learn to code.

 

so my question is how should i do this, i have tried and failed with trying to pick out individual highs and lows data and define them as above or below freezing but i can't figure out how to pick out the right number

 

my code for this part of the project is

$json_line = file_get_contents("http://api.wunderground.com/api/{key}/geolookup/forecast10day/q/$zipcode.json");

$parsed_line = json_decode($json_line);

echo $parsed_json->{'forecast'}->{'simpleforecast'}->{'forecastday'}->{'date'}->{'weekday'};

$temp_h = $parsed_line->{'forecast'}->{'simpleforecast'}->{'forecastday'}->{'high'}->{'farenheit'};

$temp_l = $parsed_json->{'forecast'}->{'simpleforecast'}->{'forecastday'}->{'low'}->{'farenheit'};

echo "Forecast for ${day} is:\n";

echo "High Temp is ${temp_h}<br />";

echo "Low Temp is ${temp_l}\n";

 

another road i was looking at going down was trying to do an array shift

 

any help would be greatly appreciated

thanks

jeremy

 

Link to comment
https://forums.phpfreaks.com/topic/258427-beginner-help-with-php-json-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.