function smarty_modifier_trim_to($text, $len) { $tail = ''; if (strstr($len, '+')) { $matches = explode('+', $len); $len = $matches[0]; $tail = $matches[1]; } $len = intval($len); if ($len > 0) { # $len is positive number if ($len < length_text($text)) { $text = substr_text($text, 0, $len); if (!is_null($tail) && $tail !== "") { $text .= $tail; } } return $text; } elseif ($len < 0) { # $len is negative number. $text = substr_text($text, 0, $len); if (!is_null($text) && $text !== "" && !is_null($tail) && $tail !== "") { $text .= $tail; } return $text; } # $len is zero or is not number. return ''; }
function smarty_modifier_trim_to($text, $len) { $len = intval($len); require_once "MTUtil.php"; if ($len < length_text($text)) { $text = substr_text($text, 0, $len); } return $text; }