PHP RSS Feed not showing



New to PHP and was just playing around with RSS feeds. I'm currently just trying to display the RSS feed from here: http://ift.tt/RwfqMp, but I think my code is broken somewhere and was hoping someone could shed some light on the issue.


This is the function I am using:



<?php

function fetch_news(){
$data = file_get_contents('http://ift.tt/RwfqMp');
$data = simplexml_load_string($data);

$articles = array();

foreach ($data->channel->item as $item){
$articles[] = array(
'title' => (string)$item->title,
'content' => (string)$item->content,
'href' => (string)$item->href,
'published' => (string)$item->published,
);
}

print_r($articles);
}

?>


When loading the page no content is displaying :( All I get is this:




Array ( )


Any Ideas on what I am doing wrong? I'm guessing it has something to do with that foreach statement.


Thanks for any help :)


No comments:

Post a Comment