首页 > IT职业 > IT生活 > PHP计算字符串的个数的方法
PHP计算字符串的个数的方法,如下代码:
function stringLength($string){
$re['utf-8'] = "/[x01-x7f]|[xc2-xdf][x80-xbf]|[xe0-xef][x80-xbf]{2}|[xf0-xff][x80-xbf]{3}/";
preg_match_all($re['utf-8'], $string, $match);
return count($match[0]);
}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2146/viewspace-2801493/ ,如需转载,请注明出处,否则将追究法律责任。