<?
/*
String-Shortening Function
Function by: Czaries [czaries@czaries.net]
Instructions:
Very simple function that cuts a string to a specified length
if it's longer than the specified length. It can also attatch
dots at the end to show the string was cut
Call by:
$string = cutstr($string);
Or, if you want a different length, you can specify it when you call it:
$string = cutstr($string,"30");
Additionally, you can choose what to add at the end of the string:
$string = cutstr($string,"30","...");
Any and all of the above calls will work properly for this function
*/
### Cuts a string to a certian length & adds a "..." to the end
function cutstr($string,$endlength="30",$end="...") {
$strlen = strlen($string);
if ($strlen > $endlength) {
$trim = $endlength-$strlen;
$string = substr("$string", 0, $trim);
$string .= $end;
}
return $string;
}
?>
Scripts & Programs © 2010 Vance Lucas | Follow me on Twitter