Hello
I’m trying to set up a script to combine more than one rss feed and display the posts in date order on a web page.
I can get this working with one rss file using the script below. Can someone please tell me how I can adapt this code so that it will work using an array of rss files please?
Thanks for any help in advance with this.
<?php
$rss = new DOMDocument();
$rss->load('http://news.sky.com/feeds/rss/business.xml');
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
);
array_push($feed, $item);
}
$limit = 10;
for($x=0;$x<$limit;$x++) {
$title = str_replace(' & ', ' & ', $feed[$x]['title']);
$link = $feed[$x]['link'];
$description = $feed[$x]['desc'];
$date = date('l F d, Y', strtotime($feed[$x]['date']));
$day = date('d', strtotime($feed[$x]['date']));
$month = date('M', strtotime($feed[$x]['date']));
echo '<div class="entry clearfix">';
echo '<div class="entry_c">';
echo '<div class="entry_date">';
echo '<div class="day">'.$day.'</div>';
echo '<div class="month">'.$month.'</div>';
echo '</div>';
echo '<div class="entry_title"><h2><a href="'.$link.'">'.$title.'</a></h2></div>';
echo '<div class="clear"></div>';
echo '<span class="page-divider"><span></span></span>';
echo '<div class="entry_content">';
echo '<p>'.$description.'</p>';
echo '</div>';
echo '</div>';
echo '</div>';
} ?>