This function takes text and, after a certain number of characters have been shown, it replaces the remaining text with " ...". It is easily customizable.
If you didn't understand what I just said, here's the function's code and an example:
Example and Output:
function preView($variable, $maxchars)
$dnum = intval($maxchars);
if(strlen($variable) > $dnum)
$splitpnt = strpos($variable," ",$dnum);
$var = substr($variable, 0, $splitpnt);
$var .= " ...";
elseif(strlen($variable) < $dnum)
$var = $variable;
That would output 'This ...' (quotes excluded) because it goes five characters before it dots the rest.
$variable = 'This is so cool!';
$new_variable = preView($variable, 5);
Disclaimer: I found this script somewhere else, renamed the function, and some of the variables names are changed.