PHP function substr() error

后端 未结 7 1954
攒了一身酷
攒了一身酷 2020-12-29 22:23

When I use substr() I get a strange character at the end

$articleText = substr($articleText,0,500);

I have an output of 500 c

相关标签:
7条回答
  • 2020-12-29 23:06

    substr is counting using bytes, and not characters.

    greek probably means you are using some multi-byte encoding, like UTF-8 -- and counting per bytes is not quite good for those.

    Maybe using mb_substr could help, here : the mb_* functions have been created specifically for multi-byte encodings.

    0 讨论(0)
提交回复
热议问题