Thorsten: Gradzeichen mit preg_replace ersetzen?

Beitrag lesen

Hallo,

hier ist der Quelltext an dem ich am verzweifeln bin:

<?PHP
$url = "http://deutsch.wunderground.com/auto/rss_full/global/stations/10708.xml";
$content = implode("", file($url));

preg_match_all("/<item>(.*?)</item>/si", $content, $results);
preg_match("/<description>(.*?)</description>/si", $results[1][0], $desc);

$arr = explode(" | ",$desc[1]);

/*
 * echo '<pre>' . print_r($arr, true) . '</pre>';
 *
 * Array
 * (
 *     [0] => Temperature: 86°F / 30°C
 *     [1] => Humidity: 74%
 *     [2] => Pressure: 29.83in / 1010hPa
 *     [3] => Conditions: Partly Cloudy
 *     [4] => Wind Direction: ESE
 *     [5] => Wind Speed: 5mph / 7km/h
 *     [6] => Updated: 10:00 PM PHT
 * )
 */

preg_match("/Temperature: (.*?)F / (.*?);C/si", $arr[0], $str);
$wetter['temp'] = $str['2'];

preg_match("/Conditions: (.*)/si", $arr[3], $str);
$wetter['verh'] = $str['1'];

preg_match("/Wind Direction: (.*)/si", $arr[4], $str);
$wetter['windr'] = $str['1'];

preg_match("/Wind Speed: (.*?)mph / (.*?)km/h/si", $arr[5], $str);
$wetter['windg'] = $str['2'];

preg_match("/Pressure: (.*?)inch / (.*?)hPa/si", $arr[2], $str);
$wetter['press'] = $str['2'];

echo '<pre>' . print_r($wetter, true) . '</pre>';
?>