/ PHP

php处理中文字符串

1.计算字符串长度

function mstrlen($string) { preg_match_all("/./us", $string, $match); return count($match[0]); }

2.截取字符串

$sub = mb_substr($str,0,10,'utf-8');

php处理中文字符串
Share this