我需要的RSS阅读器我在我的网站,该脚本做工精细测试的代码帮助,但它显示出20进,我想它限制了一些我设置(如3或6所示的例子)。
这是该代码:
<?php
//Feed URLs
$feeds = array(
"https://robertsspaceindustries.com/comm-link/rss",
);
//Read each feed's items
$entries = array();
foreach($feeds as $feed) {
$xml = simplexml_load_file($feed);
$entries = array_merge($entries, $xml->xpath("//item"));
}
//Sort feed entries by pubDate
usort($entries, function ($feed1, $feed2) {
return strtotime($feed2->pubDate) - strtotime($feed1->pubDate);
});
?>
<ul><?php
//Print all the entries
foreach($entries as $entry){
?>
<li><a href="<?= $entry->link ?>"><?= $entry->title ?></a> (<?= parse_url($entry->link)['host'] ?>)
<p><?= strftime('%m/%d/%Y %I:%M %p', strtotime($entry->pubDate)) ?></p>
<p><?= $entry->description ?></p>
<img src="<?= $entry->children('media', true)->content->attributes()->url ?>" alt="" />
</li>
<?php
}
?>
</ul>
我tryed使用一个变量来寻找一个解决方案,但我失败了...感谢您的帮助! :)