// usage: $var = word_chop($str(string), $max_words(limit of words, default: 15));
function word_chop($str, $max_words = 15) { $e = explode(' ', $str); $w = count($e); if($w > $max_words) { $str = ''; for($i=0;$i<$max_words;$i++) { $str .= ' '.$e[$i]; } $str .= '...'; } return($str); }