啥也不说了,上代码。
function sub_title($t){ $len = 50; $text = $t; return strlen($text)<=$len ? $text : (mb_substr($text,0,$len,'utf-8')."...");}View Code
试验了一下,感觉下面这段代码更好一点,代码如下:
function sub_title($title){ $len = 23; return mb_strlen($title, 'utf-8')<=$len ? $title : (mb_substr($title,0,$len,'utf-8')."..."); }View Code