I am attempting to parse Yahoo's weather XML feed via this script. The parsing itself works: I am just struggling with getting the days to correspond with today, tomorrow and the day after.
The final HTML output looks like this:
Which can be seen here: http://www.wdmadvertising.com.au/preview/cfs/index.shtml
todayMon______________19
todayTue______________26
Tue______________26
It is supposed to look like this:
Today______________(temp)
(tomrrow)______________(temp)
(day after tomorrow)______________(temp)
The PHP and HTML:
<div class="latest-weather">
<h1 class="latest-weather">Latest weather</h1>
include("class.xml.parser.php");
include("class.weather.php");
$weather_adelaide = new weather("ASXX0001", 3600, "c", $cachedir);
$weather_adelaide->parsecached();
// TODAY 1
for ($day=0; isset($weather_adelaide->forecast[$day]); $day++) {
print "<h2>today".$weather_adelaide->forecast[$day]['DAY']."</h2>";
print "<p />".$weather_adelaide->forecast[$day]['HIGH']."<br>"; }
// FORECAST 2
for ($day=1; isset($weather_adelaide->forecast[$day]); $day++) {
print "<h2>".$weather_adelaide->forecast[$day]['DAY']."</h2>";
print "<p />".$weather_adelaide->forecast[$day]['HIGH']."<br>"; }
// FORECAST 3
for ($day=2; isset($weather_adelaide->forecast[$day]); $day++) {
print "<h2>".$weather_adelaide->forecast[$day]['DAY']."</h2>";
print "<p />".$weather_adelaide->forecast[$day]['HIGH']."<br>"; }
?>
</div><!--/latest-weather-->