PHP Code:
function fetch_trimmed_title($title, $chars = -1)
{
global $vboptions;
if ($chars == -1)
{
$chars = $vboptions['lastthreadchars'];
}
if ($chars)
{
// limit to 10 lines (\n{240}1234567890 does weird things to the thread preview)
$titlearr = preg_split('#(\r\n|\n|\r)#', $title);
$title = '';
$i = 0;
foreach ($titlearr AS $key)
{
$title .= "$key\n";
$i++;
if ($i >= 10)
{
break;
}
}
$title = trim($title);
unset($titlearr);
if (strlen($title) > $chars)
{
// trim text to specified char length, then trim after last space to avoid half-words
return substr($title, 0, strrpos(substr($title, 0, $chars), ' ')) . '...';
}
else
{
return $title;
}
}
else
{
return $title;
}
}
TECK do you realize how confusing that is for me?