Limit RSS feed results

This is a follow on from the previous entry, the rss feed before returned 15 entries but lets say you only wanted maybe the last 3 entries. This example can help

require_once ‘’;
//change to your rss feed
$url = ““;
//number of items to display
$num_items = 3;
$rss = fetch_rss($url);

echo “Site: “, $rss->channel[‘title’], “<br>”;
echo “<ul>”;

$items = array_slice($rss->items, 0, $num_items);

foreach ($items as $item )
 $title = $item[title];
 $url   = $item[link];
 $description = $item[‘description’];
 echo “<li><a href=$href>$title</a><br />$description</li>”;
echo “</ul>”;


Please enter your comment!
Please enter your name here