0

我正在从 BBC 体育网站提取 RSS 源,该网站显示如下项目:

<item> 
  <title>VIDEO: Warnock on why he left Leeds</title>  
  <description>Dan Walker is joined for this week's Focus Forum by Neil Warnock, who discusses his departure from Leeds United earlier this month.</description>  
  <link>http://www.bbc.co.uk/sport/0/football/22136090</link>  
  <guid isPermaLink="false">http://www.bbc.co.uk/sport/0/football/22136090</guid>  
  <pubDate>Tue, 16 Apr 2013 08:27:55 GMT</pubDate>  
  <media:thumbnail width="66" height="49" url="http://news.bbcimg.co.uk/media/images/66985000/png/_66985898_warnock.png"/>  
  <media:thumbnail width="144" height="81" url="http://news.bbcimg.co.uk/media/images/66985000/png/_66985900_warnock.png"/> 
</item>  

我只想拉7天前已经发布的项目。到目前为止,我有:

<?php
  $cnt=0;
foreach($rss->channel->item as $item){
    if ($cnt==100) {
      break;
    }
foreach($rss->entry as $item) {
   if ($item->published) > "") {
  print_r($item);
   }
?>

对第二次 foreach 非常不确定,逐页搜索此网站以找到答案,但没有运气!

提前致谢!

4

1 回答 1

0

您应该将 RSS 提要中的值转换为 DateTime 对象,然后使用比较器

在这里查看示例#2:http: //php.net/manual/en/datetime.diff.php

于 2013-04-17T16:24:04.903 回答