Shorten string words

function limit_string_words($string,$word_limit)
{
$words = explode(' ', $string, ($word_limit + 1));
if(count($words) > $word_limit)
array_pop($words);
return implode(' ', $words);
}

0 Comments

You must be logged in to post a comment.