I usage this php code to display recent post with description. Max desc 100 word. How to display 3 dot after 100 word (like this: this is content of bla bla bla... ).
Can someone help me, please!
This is my php code:
<?php
$rss = new DOMDocument();
$rss->load('http://domain.com/feed/');
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
);
array_push($feed, $item);
}
$limit = 5;
for($x=0;$x<$limit;$x++) {
$title = str_replace(' & ', ' & ', $feed[$x]['title']);
$link = $feed[$x]['link'];
$description = $feed[$x]['desc'];
$description = substr($description, 0, 138);
$date = date('d F Y - H:m', strtotime($feed[$x]['date']));
echo '<li><strong><a href="'.$link.'" title="'.$title.'">'.$title.'</a></strong>';
echo '<br><small>'.$date.'</small>';
echo '<br>'.$description.'</br></li>';
}
?>