<?php
/*
Example usage:
$long_string="This is a very long string that I want shortened";
$short_string=trimString($long_string, 10);
echo $short_string;
Will output "This is..."
*/
function trimString($str, $len) {
If(strlen($str)>intval($len)) {
return(substr($str,0,($len-3))."...");
}
return($str);
}
?>
0 comments:
Post a Comment