Code: Select all
$thread_title = $out['title'];
if (strlen($thread_title) == 20) {
$thread_title .= '...';
}Code: Select all
$maxlength = 20;
if (strlen($thread_title) > $maxlength){
$truncatedtext = substr($thread_title, 0, $maxlength) . "...";
} else {
$truncatedtext = $thread_title;
}If you want you can amalgamate them into:
Code: Select all
$thread_title = $out['title'];
$maxlength = 20;
if (strlen($thread_title) == $maxlength) {
$thread_title .= '...';
}Code: Select all
echo 'The truncated text is: '.$thread_title;Mac