Ashokkumar's Blog for everything.
Pages
Home
Friday, January 11, 2013
php limit text by word
function limit_text($text, $limit)
{
$words = str_word_count($text, 2);
if ( count($words) > $limit)
{
$pos = array_keys($words);
$text = substr($text, 0, $pos[$limit]) . '...';
}
return $text;
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment