robixxu

[PHP] RSS Feed

Jun 30th, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.49 KB | None | 0 0
  1. <?php
  2.     $feedURL    =   'http://www.eed.usv.ro/news/backend.php';
  3.     $root       =   simplexml_load_file($feedURL);
  4.     $feed       =   array();
  5.     $items      =   array();
  6.  
  7.     $feed['title']  =   $root->channel->title;
  8.     $feed['link']   =   $root->channel->link;
  9.  
  10.     $i=0;
  11.     foreach($root->channel->item as $item){
  12.         $items[$i++]    =   array(
  13.                                     'title'         =>      $item->title,
  14.                                     'link'          =>      $item->link,
  15.                                     'description'   =>      $item->description
  16.                                     );
  17.     }
  18.     for($i=0;$i<count($items);$i++){
  19.         echo '</br><a href="'.$items[$i]['link'].'">'. $items[$i]['title'].'</a>';
  20.     }
  21. ?>
  22.  
  23. ----------------------------------------------------------------------------------------------------------
  24. <meta charset="UTF-8" />
  25. <?php
  26.     $feedURL    =   'http://fede.ro/feed/';
  27.     $root       =   simplexml_load_file($feedURL);
  28.     $feed       =   array();
  29.     $items      =   array();
  30.  
  31.     $feed['title']  =   $root->channel->title;
  32.     $feed['link']   =   $root->channel->link;
  33.  
  34.     $i=0;
  35.     foreach($root->channel->item as $item){
  36.         $items[$i++]    =   array(
  37.                                     'title'         =>      $item->title,
  38.                                     'link'          =>      $item->link,
  39.                                     'description'   =>      $item->description,
  40.                                     'comments'      =>      $item->comments,
  41.                                     'pubDate'       =>      $item->pubDate,
  42.                                     'guid'          =>      $item->guid
  43.                                     );
  44.     }
  45.  
  46.     echo '<table>';
  47.     for($i=0;$i<count($items);$i++){
  48.         echo '<tr>';
  49.         echo '<td><a href="'.$items[$i]['guid'].'">'.$items[$i]['title'].'</a></td>';
  50.         echo '</tr>';
  51.         echo '<tr>';
  52.         echo '<td>'.$items[$i]['description'].'</td>';
  53.         echo '</tr>';
  54.     }
  55.     echo '</table>';
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment