public static function truncate($str, $max_chars = 3000, $force = 1)
{
if (strlen($str) >= $max_chars) {
if ($force == 1) {
$str = substr($str, 0, $max_chars);
$espace = strrpos($str, " ");
$str = substr($str, 0, $espace) . "...";
return $str;
} else {
$showmax = $max_chars - 3;
$str = substr($str, 0, $showmax) . "...";
return $str;
}
} else {
return $str;
}
}