05-02-2008, 03:24 PM
|
#3 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
Alternatively you could only feed the first 5 items into the foreach.
PHP Code:
<?php
require_once "XML/RSS.php";
$rss =& new XML_RSS("sample.xml");
$rss->parse();
echo " <ul>\n";
// Use only the first 5 items
$items = array_slice($rss->getItems(), 0, 5);
foreach ($items as $item) {
echo "<li><a href=\"" . $item['link'] . "\">" . $item['title'] .
"</a></li>\n";
}
echo "</ul>\n";
?>
|
|
|
|