|
|
100){
// Get temperature unit C or F
$spos = strpos($wrss,'yweather:units temperature="')+strlen('yweather:units temperature="');
$epos = strpos($wrss,'"',$spos);
if ($epos>$spos){
$tempu = substr($wrss,$spos,$epos-$spos);
}
$spos = strpos($wrss,'yweather:wind chill="')+strlen('yweather:wind chill="');
$epos = strpos($wrss,'"',$spos);
if ($epos>$spos){
$temp += substr($wrss,$spos,$epos-$spos);
} else {
$temp = '-';
}
// Get city name
$spos = strpos($wrss,'yweather:location city="')+strlen('yweather:location city="');
$epos = strpos($wrss,'"',$spos);
if ($epos>$spos){
$city = substr($wrss,$spos,$epos-$spos);
}
}
return $city.' '.$temp.' °'.$tempu;
}
echo processWeather('http://xml.weather.yahoo.com/forecastrss?p=THXX0017&u=c');
?>
|
|