0

I am displaying blog RSS feeds in my website and one of my blog is soooo big but only 2-3 lines of that description should display in my website how can i do that? Please help me Thanks In Advance

Am using magpierss-0.72 to fetch rss My code is

require_once('rss_fetch.inc');

$url = 'http://rajs-creativeguys.blogspot.com/feeds/posts/default?alt=rss';

$rss = fetch_rss($url);

foreach ($rss->items as $i => $item ) { 
    $title = strtoupper ($item['title']);
    $url   = $item['link'];
    $desc = $item['description'];
    $date = $item['pubdate'];

    echo "<div class=\"blog\"><a target=\"_blank\" href=$url><h1>$title</h1>$desc<br/><br/><em>DATED : $date <br/><br/></em></a></div> ";
}

And the blog address is http://rajs-creativeguys.blogspot.in/

Cfreak
  • 19,191
  • 6
  • 49
  • 60

1 Answers1

0
 $desc = substr(0,150,$item['description']);

to get the first 150 characters.

If you want 150 words you could use

$desc = '';
$max = 150;
$arr = explode(' ', strip_tags($item['description']));
$l = count($arr);
if($l < $max) $max = $l;
for($i=0;$i<$max;++$i)
    {
    $desc .= $arr[$i] . ' ';
    }
Tschallacka
  • 27,901
  • 14
  • 88
  • 133