When pulling single data fields out, the script works great, but when I tried to run the supplied sample to get the forecast I got this error:
Warning: Invalid argument supplied for foreach() in /home/dad/public_html/weather/pxweather.class.php on line 121
My PHP version (5.2.11)
The is the code I used:
<?php
require_once("pxweather.class.php");
$w = new Weather($city = "Kahului");
$w->load();
foreach($w->getForecasts() as $forecast)
{
echo "FORECAST FOR " . $forecast['day']. ":\n";
echo $w->weatherString($forecast['weather']) . "\n";
if (isset($forecast['low_temp']))
echo "Low temperature: " . $forecast['low_temp'] . "\n";
if (isset($forecast['high_temp']))
echo "High temperature: " . $forecast['high_temp'] . "\n";
echo "Description: " . $forecast['text'] . "\n\n";
}
?>
Any ideas?