Limit the results to how many?
You can use a simple counter:
PHP Code:
<?php
$url = "http://news.google.com/?output=rss";
$rss = simplexml_load_file($url);
$limit = 10; // Change this number to however many items you want to display
$counter = 1;
if($rss)
{
$items = $rss->channel->item;
foreach($items as $item)
{
if($counter <= $limit) {
$title = $item->title;
$link = $item->link;
$description = $item->description;
$image = $item->image;
echo ' <div class="img rand" >
<img src="'.$image.'" alt="'.$title.'">
<a href="'.$link.'" target="_blank">
<img src="/overlay.gif" class="cvr" alt="'.$title.'"/></a>
<div class="desc truncate" >'.$title.'</div>
</div>';
$counter++;
}
}
}
?>
Bookmarks