Heres a quick function i made.
All it does is take X chars from your string using
substr and then sticks something on the end
code:
function shorten($string, $chars, $append = '...'){
return substr($string, 0, $chars) . $append;
}
Params:
$string - The string you want shortened
$chars - The output length (not including what you stick on the end)
$append (optional) - What you want put on the end, defaults to ...
Examples
echo shorten('foobar', 3);
will output "foo..." (without quotes)
echo shorten('eljelly really rocks', 8, 'sucks');
will ouput "eljelly sucks" (without quotes)