Possible Duplicate:
limiting number of times a loop runs in php
I am trying to break a foreach loop reading a feed of tweets - after three tweets. Would somebody help with the code I need to supplement to the one i have already.
<?php
function getTweets($Username) {
$feedURL = "http://twitter.com/statuses/user_timeline.rss?screen_name=" . $username;
$content = file_get_content($feedURL);
$tweets = new SimpleXMLElement ($content);
foreach ($tweets->channel->item as $tweet) {
echo "<ul>";
echo "<li>$tweet->description<br />$tweet->pubDate</li>";
echo "</ul>";
}
?>
}
Thanking you in advance.