Skip to content

Instantly share code, notes, and snippets.

@shigwata
Created September 29, 2014 04:43
Show Gist options
  • Select an option

  • Save shigwata/6783c8230ddd05c9b38a to your computer and use it in GitHub Desktop.

Select an option

Save shigwata/6783c8230ddd05c9b38a to your computer and use it in GitHub Desktop.
アメブロからRSS情報を取得し表示する。
<?php
/**
* アメブロからRSS情報を取得します
* @param [type] $url [description]
* @return [type] [description]
*/
function get_ameba_rss($url) {
$xml = simplexml_load_file($url);
$results = array();
foreach ($xml->channel->item as $item) {
// 広告は除外
if (preg_match('/PR/', $item->title)) {
continue;
}
$results[] = $item;
}
return $results;
}
?>
<table>
<?php
// 取得URL
$url = 'http://rssblog.ameba.jp/ebizo-ichikawa/rss20.xml';
$rss = get_ameba_rss($url);
foreach ($rss as $item) :?>
<tr>
<th width="30%"><?php echo date('Y年m月d日', strtotime($item->pubDate));?></th>
<td width="70%"><a href="<?php echo $item->link;?>" target="_blank"><?php echo $item->title;?></td>
</tr>
<?php endforeach;?>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment