PHP function substr() error

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

    ms_substr() also works excellently for removing strange trailing line breaks as well, which I was having trouble with after parsing html code. The problem was NOT handled by:

     trim() 
    

    or:

     var_dump(preg_match('/^\n|\n$/', $variable));
    

    or:

    str_replace (array('\r\n', '\n', '\r'), ' ', $text)
    

    Don't catch.

提交回复
热议问题