- preg_match: documentation ( source)
- simplexml_load_file: documentation ( source)
<?php
$xml = simplexml_load_file('http://weather.yahooapis.com/forecastrss?w=868274&u=c');
$weatherInfo = $xml->channel->item->description;
$imagePattern = '/src="(.*?)"/i';
preg_match($imagePattern, $weatherInfo, $matches);
$imageSrc = $matches[1];
$degreesPattern = '/.*?, (-?\d+) C/i';
preg_match($degreesPattern, $weatherInfo, $matches);
$degrees = $matches[1];
echo $degrees;