title: First X items in foreach loop
body: <p>This may well be a silly question to many, but I've fried my brain sorting out various things today and can't think where to start. Sorry in advance.</p>
  
  <p>I'm pulling in an RSS feed from a Wordpress site to another webpage. That is working and displaying a list of all the posts.</p>
  
  <p>I'm using this code (from another post I made):</p>
  
  <pre><code>function getFeed($feed_url) {
  
  $content = file_get_contents($feed_url);
  $x = new SimpleXmlElement($content);
  
  echo "&lt;ul&gt;";
  
  foreach($x-&gt;channel-&gt;item as $entry) {
      echo "&lt;li&gt;&lt;a href='$entry-&gt;link' title='$entry-&gt;title'&gt;" . $entry-&gt;title . "&lt;/a&gt;&lt;/li&gt;";
  }
  echo "&lt;/ul&gt;";
  }
  getFeed("http://your-wordpress-site/feed/");
  </code></pre>
  
  <p>I would however like to only show the first 8 entries.</p>
  
  <p>Would I need to use something other than a foreach loop?</p>