How to get the length of a string that is a combination of Chinese and English when trying to get the character segment? -PHP Chinese website Q&A-How do you get the length of a string that is a combination of Chinese and English when trying to obtain a character segment? -PHP Chinese website Q&A
How to get the length of a string that is a combination of Chinese and English when trying to get the character segment? -PHP Chinese website Q&A-How do you get the length of a string that is a combination of Chinese and English when trying to obtain a character segment? -PHP Chinese website Q&A
Let’s take a look and learn.
如果是既有英文又有中文的话,每个中文按照三个字符处理的(至于一个中文按照多少个字符处理与编码有关)
如下代码,运行结果为23
<?php
$str="你好世界Hello World";
$n=strlen($str);
echo $n;
?>