Skip to content

Instantly share code, notes, and snippets.

@alexmccabe
Last active August 29, 2015 14:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alexmccabe/11396025 to your computer and use it in GitHub Desktop.
Save alexmccabe/11396025 to your computer and use it in GitHub Desktop.
<?php
$local_file = 'assets/info_system/rss_feeds/feed.xml';
$result = file_get_contents($local_file);
$xml = simplexml_load_string($result);
$xml->registerXPathNamespace('yweather', 'http://xml.weather.yahoo.com/ns/rss/1.0');
$location = $xml->channel->xpath('yweather:location');
if(!empty($location)) {
foreach($xml->channel->item as $item) {
$forecast = $item->xpath('yweather:forecast');
}
foreach($forecast as $day) {
$projection[] = array(
'day' => $day['day'],
'low' => $day['low'],
'high' => $day['high'],
'code' => $day['code']
);
}
$weather = array(
'location' => $location[0]['city'][0],
'forecast' => $projection
);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment