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; }
function first_n_text($text, $n) { if (!isset($lang) || empty($lang)) { global $mt; $lang = $blog && $blog['blog_language'] ? $blog['blog_language'] : $mt->config('DefaultLanguage'); } if ($lang == 'jp') { $lang = 'ja'; } if ($lang == 'ja') { $text = strip_tags($text); $text = preg_replace('/\\r?\\n/', " ", $text); return substr_text($text, 0, $n); } else { return first_n_words($text, $n); } }