Home  >  Q&A  >  body text

请问获取字符段尝试是中英文结合的字符串怎么获取长度呢?

我是灰太狼我是灰太狼2832 days ago924

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-10-01 00:04:11

    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.

    reply
    0
  • 怪我咯

    怪我咯2017-02-10 16:55:20

    如果是既有英文又有中文的话,每个中文按照三个字符处理的(至于一个中文按照多少个字符处理与编码有关)

    如下代码,运行结果为23

    <?php
        $str="你好世界Hello World";
        $n=strlen($str);
        echo $n;
    ?>


    reply
    0
  • Cancelreply