计算字符串的长度(汉字按照两个字符计算)

2009年11月2日 | 酷码资源

计算字符串的长度(汉字按照两个字符计算)

<?
function str_len($str)
{
$length = strlen(preg_replace('/[\x00-\x7F]/', '', $str));

if ($length)
{
return
strlen($str) - $length + intval($length / 3) * 2;
}
else
{
return
strlen($str);
}
}

?>


转载文章请注明转载自:酷码资源

标签: ,

留下回复

1+8? (必须)