View Full Version : A Simple RSS Feed Phraser in PHP

08-10-2005, 09:10 AM
A Simple RSS Feed Phraser in PHP

Heres a simple RSS Feed Phraser function. Its simple and effective function. All you need to do is add it to the page you wish to display the feed.

If you want to show / display the feed all you need to do is call up the function using:


The $variables can be used to define a few options:

$url = the url of the rss feed (e.g. http://slashdot.org/slashdot.rdf)
$count = the number of titles and descriptions to display (e.g. 5)

Using this function you can display more than one rss feed in one page / file, without constantly rewriting out all the code to display the feed. The function:

function showFeed($url,$count)
//* get the xml file
$xml = simplexml_load_file($url);
//* phrase all the data from the xml so we can display it
for ($x = 0; $x < $count; $x++) {
//* this bits for if its an rss 1 feed
if (isset($xml->item)) {
$item = $xml->item[$x];
//* this bits for 0.91 rss feeds
elseif (isset($xml->channel->item)) {
$item = $xml->channel->item[$x];
//* show the headline and the description
echo "<a href=\"$item->link\">$item->title</a><br>$item->description<br><br>";
//* reset variables
//* close the function loop


08-31-2005, 16:40 PM
what does it change with the rss feed?

08-31-2005, 21:55 PM
thanks im kinda new to rss myself but i think im gonna give it a test drive

08-31-2005, 21:56 PM
yea, im new to, im trying to figure some things out still

10-05-2005, 07:23 AM
man u r gud wid php
thanks so much for sharing another awesome code

10-05-2005, 11:59 AM
this is really good post.Thanks for sharing it with us.