中文字符串截取
mb_substr( $str, $start, $length, $encoding );
- $str,需要截断的字符串
- $start,截断开始处,起始处为0
- $length,要截取的字数
- $encoding,网页编码,如utf-8,GB2312,GBK
mb_substr($str,0,4,'utf-8');//截取长度为5的字符串
中文字符串长度
mb_strlen( $str, $encoding );
- $str,要计算长度的字符串
- $encoding,网页编码,如utf-8,GB2312,GBK
mb_strlen($str,'utf-8');//获取字符串中文长度