balkan7 Posted February 24, 2008 Share Posted February 24, 2008 i need help to get weather for today and tomorow, i have code for every day, can someone help me to get for today and tomorow? code: <?php for ($day=0; isset($weather_chile->forecast[$day]); $day++) { print "<h1>Forecast Day $day</h1>"; //print_r($weather_chile->forecast[$day]); print "day: ".$weather_chile->forecast[$day]['DAY']."<br>"; // Wed print "date: ".$weather_chile->forecast[$day]['DATE']."<br>"; // 26 Oct 2005 print "low °C: ".$weather_chile->forecast[$day]['LOW']."<br>"; // 8 print "high °C: ".$weather_chile->forecast[$day]['HIGH']."<br>"; // 19 print "text: ".$weather_chile->forecast[$day]['TEXT']."<br>"; // Partly Cloudy print "imgcode: ".$weather_chile->forecast[$day]['CODE']."<br>"; // 29=Image for partly cloudy print "image: <img src=http://us.i1.yimg.com/us.yimg.com/i/us/we/52/".$weather_chile->forecast[$day]['CODE'].".gif>"; print "<hr>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/92723-help-me-whit-weather/ Share on other sites More sharing options...
Bauer418 Posted February 24, 2008 Share Posted February 24, 2008 i need help to get weather for today and tomorow, i have code for every day, can someone help me to get for today and tomorow? code: <?php for ($day=0; isset($weather_chile->forecast[$day]); $day++) { print "<h1>Forecast Day $day</h1>"; //print_r($weather_chile->forecast[$day]); print "day: ".$weather_chile->forecast[$day]['DAY']."<br>"; // Wed print "date: ".$weather_chile->forecast[$day]['DATE']."<br>"; // 26 Oct 2005 print "low °C: ".$weather_chile->forecast[$day]['LOW']."<br>"; // 8 print "high °C: ".$weather_chile->forecast[$day]['HIGH']."<br>"; // 19 print "text: ".$weather_chile->forecast[$day]['TEXT']."<br>"; // Partly Cloudy print "imgcode: ".$weather_chile->forecast[$day]['CODE']."<br>"; // 29=Image for partly cloudy print "image: <img src=http://us.i1.yimg.com/us.yimg.com/i/us/we/52/".$weather_chile->forecast[$day]['CODE'].".gif>"; print "<hr>"; } ?> Code for every day starting when? Yesterday? Today? What day does $weather_chile->forcast[0] refer to? Quote Link to comment https://forums.phpfreaks.com/topic/92723-help-me-whit-weather/#findComment-475080 Share on other sites More sharing options...
balkan7 Posted February 24, 2008 Author Share Posted February 24, 2008 no for yesterday i need for today and tomorow... this is code for day starting for ($day=0; isset($weather_chile->forecast[$day]); $day++) Quote Link to comment https://forums.phpfreaks.com/topic/92723-help-me-whit-weather/#findComment-475083 Share on other sites More sharing options...
Bauer418 Posted February 24, 2008 Share Posted February 24, 2008 I get what you want to do, I'm asking what the script currently does. What is the first day in that loop? Does the array start with yesterday or today? Or neither? Quote Link to comment https://forums.phpfreaks.com/topic/92723-help-me-whit-weather/#findComment-475084 Share on other sites More sharing options...
balkan7 Posted February 24, 2008 Author Share Posted February 24, 2008 weather.php <html> <head> </head> <body> <?php //============================================================================ //============================================================================ // Script: PHP Script "Yahoo Weather Demo" //============================================================================ // From: www.voegeli.li // Autor: marco voegeli, switzerland - >> www.voegeli.li >> // Date: 28-Oct-2005 // License/ // Usage: Open Source / for free //============================================================================ // DESCRIPTION: // This Script is the example of the class yahoo weather! It shows all // attributes of the class ad shows how to use it! //============================================================================ // Modified: Dec 2006 by Matt Brown //============================================================================ // Visit http://dowdybrown.com , the contributor of the new version. Thank you // Matt for this great and better version of the yahoo weather class! You have // done a good job! //============================================================================ // ------------------- // INCLUDES // ------------------- include("class.xml.parser.php"); include("class.weather.php"); // ------------------- // LOGIC // ------------------- // Create the new weather object! // CIXX0020 = Location Code from weather.yahoo.com // 3600 = seconds of cache lifetime (expires after that) // C = Units in Celsius! (Option: F = Fahrenheit) $timeout=3*60*60; // 3 hours if (isset($_ENV["TEMP"])) $cachedir=$_ENV["TEMP"]; else if (isset($_ENV["TMP"])) $cachedir=$_ENV["TMP"]; else if (isset($_ENV["TMPDIR"])) $cachedir=$_ENV["TMPDIR"]; else // Default Cache Directory $cachedir="/tmp"; $cachedir=str_replace('\\\\','/',$cachedir); if (substr($cachedir,-1)!='/') $cachedir.='/'; $weather_chile = new weather("MKXX0004", 3600, "c", $cachedir); // Parse the weather object via cached // This checks if there's an valid cache object allready. if yes // it takes the local object data, what's much FASTER!!! if it // is expired, it refreshes automatically from rss online! $weather_chile->parsecached(); // => RECOMMENDED! // allway refreshes from rss online. NOT SO FAST. //$weather_chile->parse(); // => NOT recommended! // ------------------- // OUTPUT // ------------------- for ($day=0; isset($weather_chile->forecast[$day]); $day++) { print "<h1>Forecast Day $day</h1>"; //print_r($weather_chile->forecast[$day]); print "day: ".$weather_chile->forecast[$day]['DAY']."<br>"; // Wed print "date: ".$weather_chile->forecast[$day]['DATE']."<br>"; // 26 Oct 2005 print "low °C: ".$weather_chile->forecast[$day]['LOW']."<br>"; // 8 print "high °C: ".$weather_chile->forecast[$day]['HIGH']."<br>"; // 19 print "text: ".$weather_chile->forecast[$day]['TEXT']."<br>"; // Partly Cloudy print "imgcode: ".$weather_chile->forecast[$day]['CODE']."<br>"; // 29=Image for partly cloudy print "image: <img src=http://us.i1.yimg.com/us.yimg.com/i/us/we/52/".$weather_chile->forecast[$day]['CODE'].".gif>"; print "<hr>"; } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/92723-help-me-whit-weather/#findComment-475090 Share on other sites More sharing options...
Bauer418 Posted February 24, 2008 Share Posted February 24, 2008 Ok you're still not understanding. What is the first day of the forecast you are gathering? Quote Link to comment https://forums.phpfreaks.com/topic/92723-help-me-whit-weather/#findComment-475092 Share on other sites More sharing options...
balkan7 Posted February 24, 2008 Author Share Posted February 24, 2008 soryy! i get this, Forecast: Sun - Clear. High: 12 Low: -1 Mon - Sunny. High: 16 Low: 1 Tue - Partly Cloudy. High: 16 Low: 2 Wed - AM Clouds/PM Sun. High: 14 Low: 2 Thu - AM Fog/PM Sun. High: 14 Low: 0 Quote Link to comment https://forums.phpfreaks.com/topic/92723-help-me-whit-weather/#findComment-475093 Share on other sites More sharing options...
balkan7 Posted February 24, 2008 Author Share Posted February 24, 2008 any idea ? Quote Link to comment https://forums.phpfreaks.com/topic/92723-help-me-whit-weather/#findComment-475309 Share on other sites More sharing options...
schilly Posted February 24, 2008 Share Posted February 24, 2008 Ok so day zero is sunday. Use the time() function to find out what day it is then assign it the appropriate value 0-6. Quote Link to comment https://forums.phpfreaks.com/topic/92723-help-me-whit-weather/#findComment-475319 Share on other sites More sharing options...
balkan7 Posted February 24, 2008 Author Share Posted February 24, 2008 can you example me whit code how to get for every day and 1 day plus like today and tomorow ? Quote Link to comment https://forums.phpfreaks.com/topic/92723-help-me-whit-weather/#findComment-475325 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.