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:
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;
Example and Output:
$variable = 'This is so cool!';
$new_variable = preView($variable, 5);
That would output 'This ...' (quotes excluded) because it goes five characters before it dots the rest.
I found this script somewhere else, renamed the function, and some of the variables names are changed.