PHP截取中英文字符串
//如果字符串长度超过10,则截取并以省略号结尾 function sub($str){ $str=(string)$str; if( mb_strlen($str,'utf-8') >10){ return mb_substr($str,0,10,'utf-8').'...'; }else{ return $str; } }
//如果字符串长度超过10,则截取并以省略号结尾 function sub($str){ $str=(string)$str; if( mb_strlen($str,'utf-8') >10){ return mb_substr($str,0,10,'utf-8').'...'; }else{ return $str; } }