Here you have my code:
<?php
$url = "http://feeds.hipertextual.com/alt1040";
$rss = simplexml_load_file($url);
if($rss) {
$items = $rss->channel->item;
foreach($items as $item) {
$title = $item -> title;
$link = $item -> link;
$description = $item -> description;
$replace = preg_replace("/<img[^>]+\>/i", "", $description);
echo utf8_decode("<h3><a href=$link>$title</a></h3>");
echo utf8_decode("<p>$replace</p>");
}
}
?>
I get the RSS from that URL and I parse it so that images don’t appear. Until here OK.
But now, I want only to be shown the first piece of news from the RSS Feed, not all the news.
If I make a count, it tells there are 25 news items.
$count = count ($items);
echo $count; //25 news...
How can I do to be only shown the first piece of news?
You can insert any number instead of 1 item in this example.