Word trim
// word trim function
function word_trim($string, $count, $ellipsis = FALSE){ $words = explode(' ', $string); if (count($words) > $count){ array_splice($words, $count); $string = implode(' ', $words); if (is_string($ellipsis)){ $string .= $ellipsis; } elseif ($ellipsis){ $string .= '…'; } } return $string;}