このスクリプトを使用して、 Yahoo の天気 XML フィードを解析しようとしています。解析自体は機能します。今日、明日、明後日に対応する日を取得するのに苦労しています。
最終的な HTML 出力は次のようになります。
ここで見ることができます: http://www.wdmadvertising.com.au/preview/cfs/index.shtml
todayMon______________19
todayTue______________26
Tue______________26
次のようになります。
Today______________(temp)
(tomrrow)______________(temp)
(day after tomorrow)______________(temp)
PHP と 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-->