Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
Thread: Dotting function
11-07-2005, 07:32 AM #1
- Join Date
- Jan 2005
- Thanked 0 Times in 0 Posts
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;
$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.