Skip to content

Instantly share code, notes, and snippets.

@wesbillman
Created April 19, 2010 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wesbillman/371526 to your computer and use it in GitHub Desktop.
Save wesbillman/371526 to your computer and use it in GitHub Desktop.
function sss_excerpt($string, $count, $string_tags = TRUE){
//it's blank, just return.
if ( '' == $string) return $string;
$string = str_replace(']]>', ']]>', $string);
$string = strip_tags($string);
$words = explode(' ', $string, $count + 1);
if (count($words)> $count) {
array_pop($words);
$string = implode(' ', $words);
}
return $string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment