This tutorial explains how to display multiple RSS Feeds in single Page .
Step 1: Create Index.Php
In this php file , we are going to use two RSS for demo. I have used Devlup.com and Linuxtree feeds for demo .
<?php
include('rssclass.php');
$feedlist = new rss('http://feeds.feedburner.com/Devlup');
echo $feedlist->display(5,"Devlup");
$feedlist = new rss('http://feeds.feedburner.com/Linuxtree');
echo $feedlist->display(5,"Linuxtree");
?>
Step 2: Create rssclass.php
< ?php
class rss {
var $feed;
function rss($feed)
{
$this->feed = $feed;
}
function parse()
{
$rss = simplexml_load_file($this->feed);
$rss_split = array();
foreach ($rss->channel->item as $item)
{
$title = (string) $item->title; // Title
$link = (string) $item->link; // Url Link
$description = (string) $item->description; //Description
$rss_split[] = ''.$title.'
';
}
return $rss_split;
}
function display($numrows,$head)
{
$rss_split = $this->parse();
$i = 0;
$rss_data = ' '.$head.' ';
while ( $i < $numrows )
{
$rss_data .= $rss_split[$i];
$i++;
}
$trim = str_replace('', '',$this->feed);
$user = str_replace('&lang=enus&format=rss_200','', $trim);
$rss_data.=' ';
return $rss_data;
}
}
?>
After Creating two Files , Now we can run the script .
Output :
Love the code, is there anyway though to adapt it to mix the feeds together and display them in order of date?
Is there a way to make the feeds load faster? I read something about making them load faster, but I cannot find that article now. I love this script. It was exactly what I was looking for, but I need the feeds to load faster. Any suggestions or script that would fix this problem?