title: XML Feeds & PHP - Limit the number of items
body: <p>I am pulling through the BBC News XML Feed. But what I want to do is limit it to say 8 or 10 items of the feed.</p>
  
  <p>How can I achieve this?</p>
  
  <p>My code is :</p>
  
  <pre><code>&lt;?php
  
    $doc = new DOMDocument();
    $doc-&gt;load('http://feeds.bbci.co.uk/news/rss.xml');
    $arrFeeds = array();
    foreach ($doc-&gt;getElementsByTagName('item') as $node) {
      $itemRSS = 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
        );
  ?&gt;
  
  &lt;h2&gt;&lt;a href="&lt;?php echo $itemRSS['link'] ;?&gt;"&gt;&lt;?php echo $itemRSS['title']; ?&gt;&lt;/a&gt;&lt;/h2&gt;
  &lt;?php  } ?&gt;
  </code></pre>
  
  <p>Thanks in advance..</p>