is PHP str_word_count() multibyte safe?

前端 未结 4 1534
Happy的楠姐
Happy的楠姐 2020-11-29 09:23

I want to use str_word_count() on a UTF-8 string.

Is this safe in PHP? It seems to me that it should be (especially considering that there is no mb_str_word_co

4条回答
  •  盖世英雄少女心
    2020-11-29 10:08

    All it does it count the number of spaces, or words in between. if you're curious, you can just make your own counting function using explode and count.

    Anytime the ascii space byte is found, it splits and that all there really is to it.

提交回复
热议问题