Skip to content

Instantly share code, notes, and snippets.

@ichii731
Created April 23, 2021 16:54
Show Gist options
  • Save ichii731/2b5ac5ee00a3a9eea005c05ad6da34b0 to your computer and use it in GitHub Desktop.
Save ichii731/2b5ac5ee00a3a9eea005c05ad6da34b0 to your computer and use it in GitHub Desktop.
<?php
// RSS取得&XMLをPurse
$rss = simplexml_load_file('https://0115765.com/feed');
$cnt = 0;
foreach($rss->channel->item as $val){
// HTML作成
echo "<a href='" . $val->link . "'>" . $val->title . "</a><br>";
echo date("Y年m月d日", strtotime($val->pubDate)) . "<br>";
$cnt++;
// 表示したい件数で終わらせる。
if ($cnt==5) {
echo "View Older Article";
break; // 必ずbreakで終わらせる。
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment