Random RSS feed

Similar to previous examples, uses magpie rss and will choose a random feed.

<?php
require_once ‘rss_fetch.inc’;
//list of rss feeds
$url = array(“http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/football/rss.xml“,
http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/golf/rss.xml“,
http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/motorsport/rss.xml“);
//get a random feed
srand(time());
$random = (rand()%3);
$rss = fetch_rss($url[$random]);

echo “Site: “, $rss->channel[‘title’], “<br>”;
echo “<ul>”;
foreach ($rss->items as $item )
{
 $title = $item[title];
 $url   = $item[link];
 $description = $item[‘description’];
 echo “<li><a href=$href>$title</a><br />$description</li>”;
}
 
echo “</ul>”;
?>

LEAVE A REPLY

Please enter your comment!
Please enter your name here

*