PHP Counter Improvement Currently I'm displaying a news feed from an XML file and using a counter to limit the number of news articles that are displayed. But I'm unsure if this is the best way to do it.

Here is my code.

&lt;?php
function get_news($feed) {

$xml = new SimpleXmlElement(uwe_get_file($feed));
$counter = 0;
foreach ($xml-&gt;channel-&gt;item as $item) {
    echo '&lt;a href="' . $item-&gt;link . '" target="_blank"&gt;' . $item-&gt;title . '&lt;/a&gt;&lt;br /&gt;' . '&lt;i&gt;' . $item-&gt;description . '&lt;/i&gt;' . '&lt;strong&gt;' . $item-&gt;pubDate . '&lt;/strong&gt;' . '&lt;br /&gt;' . '&lt;br /&gt;';
    ++$counter;
    if ($counter == 5) {
        break;
    }
}
}

?&gt;


Any suggestions on how I could improve this counter?
That's a perfectly good and valid way of doing it. Personally, I'd write $counter++ rather than ++$counter, but that's just my personal preference.