This is a function I use to display the ellipses when I want to truncate and display a summary of a larger body of text.
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<?php function truncateString($intLength = 0, $strText = "") { if ($intLength == 0) { return $strText; } if (strlen($strText) > $intLength) { preg_match("/[a-zA-Z0-9]{0, " . $intLength . "}/", $strText, $strNewText); return ($strNewText . "..."); } else { return $strText; } } ?> |