Webmaster Forum  

Go Back   Webmaster Forum > Website Design Forum > Website Design Forum
User Name
Password
Register FAQ Members List Calendar Transactions Store Search Today's Posts Mark Forums Read


A Simple RSS Feed Phraser in PHP

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-10-2005, 09:10
admans
Senior Member


Join Date: Jul 2005
Posts: 248
Trader Rating: (0)
Points: 22 (Donate)
5 F$/Referral Refer Friends
admans is on a distinguished road
Default A Simple RSS Feed Phraser in PHP

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:
PHP Code:
 showFeed($url,$count); 



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:
PHP Code:
 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
            
unset($xml);
            unset(
$item);
    
//* close the function loop
    



Enjoy!
__________________

http://img76.imageshack.us/img76/6450/sc2but4ng.gif | http://img495.imageshack.us/img495/...ogorwtan0je.gif | <a href="http://webtools.sc2.info"><img src="http://img129.imageshack.us/img129/8682/sc2webtan7ju.gif" border="1" width="100" alt="Free Webtools for all" /></a> | <a href="http://www.indexrated.com"><img src="http://img398.imageshack.us/img398/4813/listed1pb.gif" border="1" width="100" alt="Index Rated Directory - Rating Quality Sites" /></a>

Get all Games,Apps and Wallpapers Nokia, Samsung and Sony Erricson!!

admans is offline
Reply With Quote
  #2  
Old 08-31-2005, 16:40
commes
Senior Member

commes's Avatar

Join Date: Aug 2005
Location: Regina, Sask, Canada
Posts: 295
Trader Rating: (1)
Points: 76 (Donate)
5 F$/Referral Refer Friends
commes is on a distinguished road
Send a message via MSN to commes
Default Re: A Simple RSS Feed Phraser in PHP

what does it change with the rss feed?
__________________
Classic Auto's | Your Ad Here | Your Ad Here | Your Ad Here | Your Ad Here |
Your Ad Here | Your Ad Here | Your Ad Here | Your Ad Here | Your Ad Here |
Your Ad Here | Your Ad Here | Your Ad Here | Your Ad Here | Your Ad Here |
commes is offline
Reply With Quote
  #3  
Old 08-31-2005, 21:55
simpson733
Junior Member


Join Date: Aug 2005
Posts: 2
Trader Rating: (0)
Points: 4 (Donate)
5 F$/Referral Refer Friends
simpson733 is on a distinguished road
Default Re: A Simple RSS Feed Phraser in PHP

thanks im kinda new to rss myself but i think im gonna give it a test drive
simpson733 is offline
Reply With Quote
  #4  
Old 08-31-2005, 21:56
commes
Senior Member

commes's Avatar

Join Date: Aug 2005
Location: Regina, Sask, Canada
Posts: 295
Trader Rating: (1)
Points: 76 (Donate)
5 F$/Referral Refer Friends
commes is on a distinguished road
Send a message via MSN to commes
Default Re: A Simple RSS Feed Phraser in PHP

yea, im new to, im trying to figure some things out still
__________________
Classic Auto's | Your Ad Here | Your Ad Here | Your Ad Here | Your Ad Here |
Your Ad Here | Your Ad Here | Your Ad Here | Your Ad Here | Your Ad Here |
Your Ad Here | Your Ad Here | Your Ad Here | Your Ad Here | Your Ad Here |
commes is offline
Reply With Quote
  #5  
Old 10-05-2005, 07:23
unknowngiver
Junior Member


Join Date: Jun 2005
Posts: 24
Trader Rating: (0)
Points: 4 (Donate)
5 F$/Referral Refer Friends
unknowngiver is on a distinguished road
Default Re: A Simple RSS Feed Phraser in PHP

man u r gud wid php
thanks so much for sharing another awesome code
unknowngiver is offline
Reply With Quote
  #6  
Old 10-05-2005, 11:59
italks
Member


Join Date: Oct 2005
Posts: 51
Trader Rating: (0)
Points: 0 (Donate)
5 F$/Referral Refer Friends
italks is on a distinguished road
Default Re: A Simple RSS Feed Phraser in PHP

this is really good post.Thanks for sharing it with us.
italks is offline
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Resources : | Advertise at FHF | itextLink.com| Reseller Hosting| TextDot| iNamePros| Any Webmaster| Web Host| Dep3|


All times are GMT -4. The time now is 14:47.


Powered by: vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.