/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * Truncate a string to a certain length if necessary, * optionally splitting in the middle of a word, and * appending the $etc string or inserting $etc into the middle. * @param string * @param integer * @param string * @param boolean * @param boolean * @return string */ function truncate($string, $length = 80, $etc = '...',$break_words = false, $middle = false) { if ($length == 0) return ''; if (!$break_words && !$middle) { } if(!$middle) { } else { } } else { return $string; } }