欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

php生成rss订阅

程序员文章站 2022-06-18 16:13:51
//$news为重里取出的数组 $host = $_server['http_host']; $xmls = '
//$news为重里取出的数组

$host = $_server['http_host'];

$xmls = '<?xml version="1.0" encoding="utf-8"?>

<rss version="2.0" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:trackback="https://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="https://wellformedweb.org/commentapi/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/">

<channel>';

foreach ($news as $keys => $values) {

//foreach ($values as $key1 => $value1) {

$xmls .= "<item><title>".$values["title"]."</title>"; 

        $xmls .= "<link>https://$host/news.php?id=".$values['id']."</link>";

        //$xmls .= "<description><![$value1[description]]></description>";

        //$xmls .= "<pubdate>".$values["addtime"]."</pubdate>";

        $xmls .= "<dc:creator>$host</dc:creator>";

        //$xmls .= "<description>".$values["addtime"]."</description>";

        $xmls .=  "<category><![cdata[".$values["content"]."]]></category></item>";

        //$xmls .= "</channel>";

//}

}

$xmls .= "</channel></rss>";

echo $xmls;