Revision: 5365
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 3, 2008 12:21 by melvitax
Initial Code
/* returns text limited by a specified length of characters but keeping words intact. the final character count will not be exact since it is affected by the possible removing of the a long word or by the addition of the ellipsis. paramaters: string - the input string chars - the length of characters wanted elli - the ellipsis to be used, defaults to '...' */ function shorten($string='', $chars=20, $elli='...'){ list($new_string, $elli)= explode("\n", wordwrap($string, $chars, "\n", false)); return ( $elli ) ? $new_string.'...' : $new_string; }
Initial URL
Initial Description
Initial Title
Shorten text without braking words
Initial Tags
Initial Language
PHP