Skip to content

Instantly share code, notes, and snippets.

@phoenixg
Created December 6, 2013 10:17
Show Gist options
  • Select an option

  • Save phoenixg/7821517 to your computer and use it in GitHub Desktop.

Select an option

Save phoenixg/7821517 to your computer and use it in GitHub Desktop.
generate-xml-rss-feed-with-php
<?php
// http://www.9lessons.info/2009/03/generate-xml-rss-feed-with-php.html
$items = array(
array('title' => 'aaa', 'link' => 'www.google.com', 'description' => 'aaaaaaaaaaa'),
array('title' => 'bbb', 'link' => 'www.yahoo.com', 'description' => 'bbbbbbbbbbb'),
);
header("Content-type: text/xml");
echo "<?xml version='1.0' encoding='UTF-8'?>
<rss version='2.0'>
<channel>
<title>这是标题</title>
<link>http://www.test.com</link>
<description>这是描述</description>
<language>en-us</language>";
foreach($items as $k => $item){
echo "<item>
<title>".$item['title']."</title>
<link>".$item['link']."</link>
<description>".$item['description']."</description>
</item>";
}
echo "</channel></rss>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment