请问获取字符段尝试是中英文结合的字符串怎么获取长度呢?
我是灰太狼
我是灰太狼 2017-02-10 16:54:52
0
2
867
我是灰太狼
我是灰太狼

reply all (2)
数据分析师

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

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


      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!