<?php $xml = simplexml_load_file('http://rss.fnn-news.com/fnn_news.xml'); echo "<ul>"; foreach($xml->channel->item as $entry){ $entrydate = date ("Y.m.d",strtotime ($entry->pubDate)); echo "<li>$entrydate<a href='$entry->link'>$entry->title</a></li>"; } echo "</ul>"; ?>
画像付き
reference:preg_match
Perform a regular expression match
<?php $xml = simplexml_load_file('http://rss.fnn-news.com/fnn_news.xml'); foreach($xml->channel->item as $entry){ echo "<article>"; // sitelink $site_title = $xml->channel->title; $site_link = $xml->channel->link; $site_titlelink = "<a href='$site_link'>$site_title</a>"; echo $site_titlelink; // date $date = date ("Y.m.d",strtotime($entry->pubDate)); echo $date; //article link $titlelink = "<a href='$entry->link'>$entry->title</a>"; echo $titlelink; // picture preg_match('/<img.*>/i', $entry->description, $entryimg); echo $entryimg[0]; echo "</article>"; } ?>