How to read RSS Feed in PHP

There are several ways to read RSS feed in PHP, but this one is surely one of the easiest.


$feed = file_get_contents(‘’);
$rss = new SimpleXmlElement($feed);

foreach($rss->channel->item as $entry) {
echo “<p><a href=’$entry->link’ title=’$entry->title’>” . $entry->title . “</a></p>”;


4 thoughts on “How to read RSS Feed in PHP

  1. jordan

    Is there a way to reduce how many to display? For example I would like to display only 5 instead of the whole rss feed.

Leave a Reply

Your email address will not be published. Required fields are marked *

1 + five =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>