计算字符长度,中文算2个(utf8编码)
ecshop里面拿出来的
ecshop里面拿出来的
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);
}
}
- 上一篇:PHP Command line
- 下一篇:取得客户端IP
精彩图集
精彩文章






