Advertisement
villers

Untitled

Nov 14th, 2014
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. <?php
  2.  
  3. namespace system\helper;
  4.  
  5. class MyRss
  6. {
  7.  
  8.     public static function parse($url)
  9.     {
  10.         $rss = simplexml_load_file($url);
  11.         echo '<div class="text-center">'
  12.             .'<h2>'.$rss->channel->title.'</h2>'
  13.             .'<p>'.$rss->channel->description.'</p>'
  14.             .'<em><a href="'.$rss->channel->link.'">'.$rss->channel->link.'</a></em>'
  15.             .'</div>';
  16.  
  17.         if(isset($rss->channel->item))
  18.             foreach ($rss->channel->item as $item) {
  19.               echo '<div>
  20.                       <em class="pull-right">'.date("d/m/Y",strtotime($item->pubDate)).'</em>
  21.                       <h3>'.$item->title.'</h3>
  22.                       <p>'.$item->description.'</p>
  23.                       <a href="'.$item->link.'">Lire tout l\'article</a>
  24.                    </div>
  25.                    <hr>';
  26.             }
  27.     }
  28.  
  29.     public static function notValide($url)
  30.     {
  31.         return (@simplexml_load_file($url) == false);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement