Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace system\helper;
- class MyRss
- {
- public static function parse($url)
- {
- $rss = simplexml_load_file($url);
- echo '<div class="text-center">'
- .'<h2>'.$rss->channel->title.'</h2>'
- .'<p>'.$rss->channel->description.'</p>'
- .'<em><a href="'.$rss->channel->link.'">'.$rss->channel->link.'</a></em>'
- .'</div>';
- if(isset($rss->channel->item))
- foreach ($rss->channel->item as $item) {
- echo '<div>
- <em class="pull-right">'.date("d/m/Y",strtotime($item->pubDate)).'</em>
- <h3>'.$item->title.'</h3>
- <p>'.$item->description.'</p>
- <a href="'.$item->link.'">Lire tout l\'article</a>
- </div>
- <hr>';
- }
- }
- public static function notValide($url)
- {
- return (@simplexml_load_file($url) == false);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement