SHARE
TWEET

Forecast PHP

a guest May 4th, 2012 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. // FORECAST //////////////////////////////////////////////////////////////////////////////////////////
  3.  
  4. $QueryForecastDecode = json_decode('Wunderground URL geolookup/conditions/forecast/q/autoip.xml');
  5.  
  6. // build forecast array // forecast array structure: Day, Hi, Lo, ForecastText, ForecastIconURL, PrecipPercent
  7. $f = 0;
  8. $ForecastArray = array();
  9. while ($QueryForecastDecode->{'forecast'}->{'simpleforecast'}->{'forecastday'}[$f]) {
  10.         $Forecasts = $QueryForecastDecode->{'forecast'}->{'simpleforecast'}->{'forecastday'}[$f];
  11.         $ForecastArray[$f] = array(
  12.                 $Forecasts->{'date'}->{'weekday_short'},
  13.                 $Forecasts->{'high'}->{'fahrenheit'},
  14.                 $Forecasts->{'low'}->{'fahrenheit'},
  15.                 $Forecasts->{'conditions'},
  16.                 $Forecasts->{'icon_url'},
  17.                 $Forecasts->{'pop'}
  18.         );
  19.         $f++;
  20. }
  21.  
  22. ?>
  23. <DOCTYPE html>
  24.  
  25. <html>
  26.  
  27. <body>
  28.  
  29. <?php echo $ForecastArray; ?>
  30.  
  31. </body>
  32. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top