php - Count Chinese characters in a string
某草草
某草草 2017-06-27 09:18:04
0
1
707
$str = '欧耶123';
//中文字节
$zl = strlen($str) - mb_strlen($str,'utf8');
//英文字节
$yl = mb_strlen($str, 'utf8') - $zl / 2;

中文个数 
$znum = $zl /2;

Can’t figure out why it’s calculated like this?

某草草
某草草

reply all(1)
阿神
mb_substr()中文一个字算3个字节,截取中文设置参数utf-8

mb_strlen($str, 'utf-8'),每个中文一个
mb_strlen($str, 'gb2312'),每个中文2个
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template