$max_length) { if ($keep_word) { $text = substr($text, 0, $max_length + 1); if ($last_space = strrpos($text, ' ')) { $text = substr($text, 0, $last_space); $text = rtrim($text); $text .= $cut_off; } } else { $text = substr($text, 0, $max_length); $text = rtrim($text); $text .= $cut_off; } } return $text; } ?>