PHP function substr() error

后端 未结 7 1992
攒了一身酷
攒了一身酷 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:03

    Use mb_substr instead, it is able to deal with multiple encodings, not only single-byte strings as substr:

    $articleText = mb_substr($articleText,0,500,'UTF-8');
    

提交回复
热议问题