Revision: 41337
Updated Code
at February 25, 2011 06:32 by chrs
Updated Code
function c_excerpt( $string, $max_words, $max_characters ){ if(str_word_count($string, 0) > (int)$max_words){ return substr($string, 0, strpos($string, ' ', $max_characters)) . "..."; } else { return $string; } }
Revision: 41336
Updated Code
at February 23, 2011 07:23 by chrs
Updated Code
function c_excerpt( $string, $max_words, $max_characters ){ return ( str_word_count($string, 0) > (int)$max_words ? substr($string, 0, strpos($string, ' ', $max_characters)) . "..." : $string ); }
Revision: 41335
Updated Code
at February 23, 2011 07:22 by chrs
Updated Code
function c_excerpt( $string, $max_words, $max_characters ){ if(str_word_count($string, 0) > (int)$max_words){ return substr($string, 0, strpos($string, ' ', $max_characters)) . "..."; } else { return $string; } }
Revision: 41334
Updated Code
at February 19, 2011 10:09 by chrs
Updated Code
function c_excerpt( $string, $max_words, $max_characters ){ if(str_word_count($string, 0) > (int)$max_words){ $excerpt = implode(' ', array_slice(str_word_count($string,1), 0, (int)$max_words) ); if (strlen($excerpt) > (int)$max_characters){ $excerpt = implode(' ', array_slice( str_word_count( substr($excerpt, 0, (int)$max_characters) ,1), 0, -1) ); } return $excerpt . "..."; } else if (strlen($string) > (int)$max_characters){ return implode(' ', array_slice( str_word_count( substr($string, 0, (int)$max_characters) ,1), 0, -1) ) . "..."; } else { return $string; } }
Revision: 41333
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 16, 2011 10:23 by chrs
Initial Code
function c_excerpt( $string, $max_words, $max_characters ) { return ( str_word_count($string, 0) > (int)$max_words ? implode(' ', array_slice(str_word_count($string,1), 0, (int)$max_words) ) . "...": strlen($string) > (int)$max_characters ? implode(' ', array_slice( str_word_count( substr($string, 0, (int)$max_characters) ,1), 0, -1) ) . "..." : $string ); }
Initial URL
Initial Description
Initial Title
Custom Length Excerpt
Initial Tags
Initial Language
PHP