
Kevin - 2009-05-13 15:12:00 -
In reply to message 7 from houssem
Hi,
To have a better understanding, you need to know how the object is constructed, for this we can use a var_dump
include 'class.weather.php';
$data = new YWeather('UKXX0106', 'c');
$channel = $data->channel();
$item = $data->item();
var_dump($item);
the result:
----
object(stdClass)#9 (2) {
["condition"]=>
object(stdClass)#10 (4) {
["text"]=>
object(SimpleXMLElement)#8 (1) {
[0]=>
string(13) "Light Drizzle"
}
["code"]=>
object(SimpleXMLElement)#11 (1) {
[0]=>
string(1) "9"
....
Now, if I want to get the forecast for tomorow, I use a loop :
include 'class.weather.php';
$data = new YWeather('UKXX0106', 'c');
$channel = $data->channel();
$item = $data->item();
foreach($item->forecast as $key => $value) {
echo $key . " " . $value->text . "\n";
}