Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function short_str($str, $max = 20) {
- $str = trim($str);
- if (strlen($str) > $max) {
- $s_pos = strpos($str, ' ');
- $cut = $s_pos === false || $s_pos > $max;
- $str = wordwrap($str, $max, ';;', $cut);
- $str = explode(';;', $str);
- $str = $str[0] . '...';
- }
- return $str;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement