Here is a PHP angle, and won't cut a word in half...
function MakeHeadLine($length, $text) {
if(strpos($text, " ")){
if(strlen($text) > $length) {
$text = substr($text,0,strrpos(substr($text,0,$length)," "))."...";
}
return $text;
} else {
return substr($text,0,$length)."...";
}
}
// Usage
$text = "This is a test to see exactly what is concatenated.";
echo MakeHeadLine(20, $text);
I use this for a news script I wrote (to display the headlines). Basically, here's how it works:
If the length of the text is larger than the length you pass to the funtion, then it concatenates it and adds the "..." to the end. The function won't cut in the middle of a word, and instead, it goes to the last space before the defined length. If there are no spaces in the text, then it just concatenates at the defined length, and adds the "...".
There's no error checking for whether the variables are passed to the function, so you'll have to add those in yourself if you want them in there.