Thread: what a headache
View Single Post
Old 05-02-2008, 03:24 PM   #3 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

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(), 05);

foreach (
$items as $item) {

echo 
"<li><a href=\"" $item['link'] . "\">" $item['title'] .
"</a></li>\n";

}

echo 
"</ul>\n";
?>
Salathe is offline  
Reply With Quote
The Following User Says Thank You to Salathe For This Useful Post:
julianochrist (05-03-2008)