Display Excerpts From an RSS Feed
A PHP5 script that reads an RSS file and outputs short customisable excerpts to HTML, with 'read more' links leading to the full story.
Works in modern browsers and IE7+
$count) { $words = array_slice($words, 0, $count); $string = implode(' ', $words).'...'; } return $string; } $xml = simplexml_load_file($rss_file); echo ''.$rss_title.'
'."\n"; echo '- ';
foreach ($xml->channel->item as $item) {
echo '
-
'.$item->title.'
'.excerpt($item->description, $words).' ';
}
echo "\n
More demos and snippets
Did you find this useful? There are more demos and code snippets this way.