php - about limiting rss feed content -
i displaying blog rss feeds in website , 1 of blog soooo big 2-3 lines of description should display in website how can that? please me in advance
am using magpierss-0.72 fetch rss 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 $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 blog address http://rajs-creativeguys.blogspot.in/
$desc = substr(0,150,$item['description']);
to first 150 characters.
if want 150 words 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] . ' '; }
Comments
Post a Comment