I assume he's talking about ensuring that some [not-so]-friendly blog respondent enters some gobbledygook string that will ruin his site's appearance.
I'm just now looking for something on the <wbr /> tag (thanks, gb!) However, there are a number of PHP possibilities in the manual's user notes on [man]strlen[/man] and maybe some other similar functions:
// courtesy of 'php a+ capcarerre d.t 0rg'
function nicetrim ($s) {
// limit the length of the given string to $MAX_LENGTH char
// If it is more, it keeps the first $MAX_LENGTH-3 characters
// and adds "..."
// It counts HTML char such as á as 1 char.
//
$MAX_LENGTH = 22;
$str_to_count = html_entity_decode($s);
if (strlen($str_to_count) <= $MAX_LENGTH) {
return $s;
}
$s2 = substr($str_to_count, 0, $MAX_LENGTH - 3);
$s2 .= "...";
return htmlentities($s2);
}
I see no reason why you couldn't even insert the ellipsis (or probably a hyphen would be preferred) and a space and return the entire string...
Of course, I could be missing Piers' point entirely.
HTH,