Skip to content

Instantly share code, notes, and snippets.

@brettstimmerman
Created July 22, 2009 20:17
Show Gist options
  • Select an option

  • Save brettstimmerman/152245 to your computer and use it in GitHub Desktop.

Select an option

Save brettstimmerman/152245 to your computer and use it in GitHub Desktop.

Revisions

  1. brettstimmerman created this gist Jul 22, 2009.
    24 changes: 24 additions & 0 deletions rssfeed.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    <?php
    function getItems() {
    $items = array();
    // Get items from somewhere
    return $items;
    }

    echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
    ?>
    <rss version="2.0">
    <channel>
    <title>Simple RSS 2.0 Feed</title>
    <link>http://www.example.com</link>
    <description>Simple RSS 2.0 Feed</description>
    <?php foreach(getItems() as $item): ?>
    <item>
    <title><?php echo $item['title']; ?></title>
    <link><?php echo $item['url']; ?></link>
    <description><?php echo $item['description']; ?></description>
    <pubDate><?php echo date('r', $item['date']); ?></pubDate>
    </item>
    <?php endforeach; ?>
    </channel>
    </rss>