title: loading rss feed into php
body: <p>What's the best way to load an RSS feed into a PHP feed?</p>
  
  <p>I also want to handle the <code>media:content</code> problems to display a image.
  At this moment I have the following code but I don't know if this is the best.</p>
  
  <pre><code>&lt;?php
      $rss = new DOMDocument();
      $rss-&gt;load('http://www.hln.be/rss.xml');
      $feed = array();
      foreach ($rss-&gt;getElementsByTagName('item') as $node) {
          $item = array ( 
              'title' =&gt; $node-&gt;getElementsByTagName('title')-&gt;item(0)-&gt;nodeValue,
              'desc' =&gt; $node-&gt;getElementsByTagName('description')-&gt;item(0)-&gt;nodeValue,
              'link' =&gt; $node-&gt;getElementsByTagName('link')-&gt;item(0)-&gt;nodeValue,
              'date' =&gt; $node-&gt;getElementsByTagName('pubDate')-&gt;item(0)-&gt;nodeValue,
              'media' =&gt; $node-&gt;getElementsByTagName('media:content url')-&gt;item(0)-&gt;nodeValue,
  
              );
          array_push($feed, $item);
      }
      $limit = 20;
      for($x=0;$x&lt;$limit;$x++) {
          $title = str_replace(' &amp; ', ' &amp;amp; ', $feed[$x]['title']);
          $link = $feed[$x]['link'];
          $description = $feed[$x]['desc'];
          $date = date('l F d, Y', strtotime($feed[$x]['date']));
          $image = $feed[$x]['media'];
  
          echo '&lt;p&gt;&lt;strong&gt;&lt;a href="'.$link.'" title="'.$title.'"&gt;'.$title.'&lt;/a&gt;&lt;/strong&gt;&lt;br /&gt;';
          echo '&lt;small&gt;&lt;em&gt;Posted on '.$date.'&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;';
          echo '&lt;p&gt;'.$description.'&lt;/p&gt;';
          echo '&lt;img src="' . $image . '"/&gt;';
  
      }
  ?&gt;
  </code></pre>