Thread: what a headache
View Single Post
Old 05-02-2008, 04:16 AM   #1 (permalink)
julianochrist
The Visitor
 
julianochrist's Avatar
 
Join Date: Apr 2008
Posts: 3
Thanks: 3
julianochrist is on a distinguished road
Confused what a headache

hello... here's the code
what i wanted to know is how do I list only the 5 first items from the xml? the foreach is taking all items from the xml code.


<?php
require_once "XML/RSS.php";

$rss =& new XML_RSS("sample.xml");
$rss->parse();

echo " <ul>\n";


foreach ($rss->getItems() as $item) {

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

}

echo "</ul>\n";
?>
julianochrist is offline  
Reply With Quote