rss中的过滤小时数解析php

时间:2015-06-27 03:29:04

标签: php rss

我有一个php文件,从其他页面获取rss feed并在我自己的页面上实现它们...问题是如何按小时过滤rss feed?

 <?php
     $html = "";
     $url = "http:www.yoursite.com/rss";
     $xml = simplexml_load_file($url);
     for($i = 0; $i < 1; $i++){
         $title = $xml->channel->item[$i]->title;
         $link = $xml->channel->item[$i]->link;
         $description = $xml->channel->item[$i]->description;
         $pubDate = $xml->channel->item[$i]->pubDate;
         $pubDate = strftime("%Y-%m-%d" "%H:%M:%S", strtotime($pubDate));
         //%H shows the pubDate Hour

         $html .= "<h3>$title</h3>";
         $html .= "$description";
         $html .= "<br /><a href='$link'>Weiterlesen</a>";
         $html .= "<br /><br />$pubDate";
    }
    echo $html;
?>

目标就像拥有例如晚上10点发布的所有Feed一样!

1 个答案:

答案 0 :(得分:0)

是否可以将xml对象放入数组中并查看该值是否存在。

$var = array ('1pm','2pm','10pm')

if (in_array('10pm', $var, true)) {

echo 'this is 10pm';

}
相关问题