PHP Code:
function chopPost($varb, $num) {
$dnum = intval($num);
if (strlen($varb) > $dnum) {
$nvarb = substr($varb, 0, $dnum);
}
elseif(strlen($varb) < $dnum) {
$nvarb = $varb;
}
return $nvarb;
}
If the string contains characters that exceed the limit, the function returns the number of characters specified. If the string contains characters less than the limit, the function returns the full string. Naturally $post should contain the forum post and 50 represents the amount of characters you wish to display. Hope this helps, Enjoy!
PHP Code:
echo chopPost($post, 50);