PHP / Magento Word Limiter

Hi all,
How to implement Read More functionality trim by word
you have assign this function your module helper file and use it 

function WordLimiter($text,$limit=20){
$explode = explode(‘ ‘,$text);
$string  = ”;
$dots = ‘…’;
if(count($explode) <= $limit){
$dots = ”;
}
for($i=0;$i<$limit;$i++){
$string .= $explode[$i].” “;
}
return $string.$dots;
}

reference link : magesam.wordpress.com/2013/04/11/php-word-limiter

0 comments: