![]() |
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"; ?> |
PHP Code:
|
Alternatively you could only feed the first 5 items into the foreach.
PHP Code:
|
i didnt get it... so $rss->items() return an array?
|
Quote:
|
Why not use a FOR loop?
|
Quote:
$rss->getItems() returns an array. Quote:
|
| All times are GMT. The time now is 11:54 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0