LastRSS makes displaying RSS feed easy. Here’s an example:
<?php
// include lastRSS
include "./lastRSS.php";
// Create lastRSS object
$rss = new lastRSS;
// Set cache dir and cache time limit (1200 seconds)
// (don't forget to chmod cahce dir to 777 to allow writing)
$rss->cache_dir = './temp';
$rss->cache_time = 1200;
// Try to load and parse RSS file
if ($rs = $rss->get('http://www.law.gmu.edu/rss/news_all')) {
// Show website logo (if presented)
if ($rs[image_url] != '') {
echo "<a href=\"$rs[image_link]\"><img src=\"$rs[image_url]\" alt=\"$rs[image_title]\" /></a>\n";
}
// Show clickable website title
echo "<h1><a href=\"$rs[link]\">$rs[title]</a></h1>\n";
// Show website description
echo "<p>$rs[description]</p>\n";
// Show last published articles (title, link, description)
echo "<ul>\n";
foreach($rs['items'] as $item) {
echo "\t<li><a href=\"$item[link]\">".$item['title']."</a>".$item['description']."</li>\n";
}
echo "</ul>\n";
}
else {
echo "Error: It's not possible to reach RSS file...\n";
}
?>