Apr 302009
neat_trim($your_text, 100);
function neat_trim( $string, $n, $close = '…' ) {
$len = strlen( $string );
if ($len > $n) {
preg_match('/(.{' . $n . '}.*?)b/', $string, $matches);
return rtrim($matches[1]) . $close;
} else {
return $string;
}
}
Sorry, the comment form is closed at this time.