Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //tronca le stringhe conservando le parole
- //#abstract #stringhe #truncate
- //$text -> stringa da torncare
- //$length -> numero di caratteri
- //$more -> parte finale
- function truncate_str($text, $length, $more = '...') {
- $length = abs((int)$length);
- if(strlen($text) > $length) {
- $text = preg_replace("/^(.{1,$length})(\s.*|$)/s", '\\1' . $more, $text);
- }
- return($text);
- }
Advertisement
Add Comment
Please, Sign In to add comment