Error with my Limit String Length code...
Posted: Tue Apr 11, 2006 1:50 pm
I can't seem to see what is wrong with this code:
It always prints the full string rather than the cut down version??
Code: Select all
<? // Limit Breif to 10 characters in User Profile
$new_brief = $user_brief;
$max_length = 10;
function truncate_string($new_brief, $max_length){
if (strlen($new_brief) > $max_length) {
$new_brief = substr($new_brief,$max_length);
$new_brief .= '...';
}
return $new_brief;
}
echo nl2br($new_brief);
?>