/*
获取中英文数
$str string 字符串
$type int 要获取的类型 0英文 1中文
return int
*/
function getStrlen($str, $type = 0)
{
$count = 0;
$newStr = preg_replace('/[^\x{4e00}-\x{9fa5}]/u', '', $str);
$count = mb_strlen($newStr,"utf-8");
if ($type == 0) {
$count = mb_strlen($str,"utf-8") - $count;
}
return $count;
}
格式化输出代码
echo '<pre>';
print_r($list); echo '</pre>';