PHP function substr() error

后端 未结 7 1986
攒了一身酷
攒了一身酷 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 22:51

    You are trying to cut unicode character.So i preferred instead of substr() try mb_substr() in php.

    substr()

    substr ( string $string , int $start [, int $length ] )
    

    mb_substr()

    mb_substr ( string $str , int $start [, int $length [, string $encoding ]] )
    

    For more information for substr() - Credits => Check Here

提交回复
热议问题