Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //truncate a string only at a whitespace
- function truncate($text, $length) {
- $length = abs((int)$length);
- if(strlen($text) > $length) {
- $text = preg_replace("/^(.{1,$length})(\s.*|$)/s", '\\1...', $text);
- }
- return($text);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement