截取中文字符长度(中文、字母都有效)

以下给大家分享下:“中文字符长度,和截取中文字符(字母汉字通用)”


样例:先算出字符的长度,在截取显示,日过字符长度超过6就用...取代

echo '<meta http-equiv="content-type" content="text/html;charset=utf-8"/>';

$CustomizedInfo = '美日汇购物返利网http://www.hnzyxok.com/';
 if(mb_strlen($CustomizedInfo,'utf-8') >6){
     echo mb_substr($CustomizedInfo,0,6,'utf-8').'...';
 }else{
echo $CustomizedInfo;
}
 
exit;
posted on 2015-03-31 16:57  gcczhongduan  阅读(147)  评论(0)    收藏  举报