PHPとRSSを使用して最新記事を取得

/* $num = 5;//RSS取得件数 date_default_timezone_set('Asia/Tokyo'); $rssUrl=array( 'http://ntrblog.com/index.rdf', //'https://www.google.com/alerts/feeds/02561088435291736243/9632300431640671365',//サイトurl ); //magpierss require_once('magpierss-0.72/rss_fetch.inc'); define('MAGPIE_OUTPUT_ENCODING','UTF-8');//encode define('MAGPIE_CACHE_AGE','30');//cache foreach ($rssUrl as $no => $rss_url) { if ($rss_url != '') { //URLからRSSを取得 $rss = @fetch_rss($rss_url); if ($rss != NULL) { for ($i=0; $iitems); $i++) { $rss->items[$i]["site_title"] = $rss->channel["title"]; $rss->items[$i]["site_link"] = $rss->channel["link"]; } //itemsを格納 $rssItemsArray[] = $rss->items; } } } $concatArray = array(); if (is_array($rssItemsArray)) { for($i=0;$i $values) { var_dump($values); //RSSの種類によって日付を取得 if(@$values['published']){$date = $values['published'];} elseif(@$values['created']){$date = $values['created'];} elseif($values['pubdate']){$date = $values['pubdate'];} elseif($values['dc']['date']){$date = $values['dc']['date'];} $date=date("Y-m-d H:i:s",strtotime($date)); //Filter $nowtime = date("Y-m-d H:i:s",strtotime( "now" ));//現在時刻の取得 if($date > $nowtime){//未来記事の排除 }elseif(preg_match("/AD/", $values["title"])){//広告記事の排除 }elseif(preg_match("/PR/", $values["title"])){ }else{ //値の定義 $title=$values["title"]; $link=$values["link"]; $site_title=$values["site_title"]; $site_link=$values["site_link"]; //記事ごとに必要な項目を抽出 $rssArray[]=array($date, $title, $link, $site_title, $site_link); }// }// //ソート function cmp($a, $b) { if ($a[0] == $b[0]) return 0; return ($a[0] > $b[0]) ? -1 : 1; } if($rssArray) { usort($rssArray, 'cmp'); } if(count($rssArray) > $num){$count=$num;} else{$count=count($rssArray);} for ($i=0; $i<$count; $i++) { $date=date("Y-m-d H:i:s",strtotime($rssArray[$i][0])); $title=$rssArray[$i][1]; $link=$rssArray[$i][2]; $site_title=$rssArray[$i][3]; $site_link=$rssArray[$i][4]; $datelink = "
$date"; $titlelink = "$title"; $site_titlelink = "[$site_title]
"; echo "$datelink$titlelink$site_titlelink";//(確認用) } }*/ ?>