28 $break_words =
false, $middle =
false)
33 if (strlen($string) > $length) {
34 $length -= min($length, strlen($etc));
35 if (!$break_words && !$middle) {
36 $string = preg_replace(
'/\s+?(\S+)?$/',
'', substr($string, 0, $length+1));
39 return substr($string, 0, $length) . $etc;
41 return substr($string, 0, $length/2) . $etc . substr($string, -$length/2);