utf-8 获取字符串字数

如果支持mb_strlen();的话就用mb_strlen();

否则的话可以用这个函数

function utf8_strlen($string = null) {
        // 将字符串分解为单元
        preg_match_all("/./us", $string, $match);
        // 返回单元个数
        return count($match[0]);        
    }

你可能感兴趣的:(utf-8 获取字符串字数)