PHP 从字符串中删除换行符

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 从字符串中删除换行符相关的知识,希望对你有一定的参考价值。

// To remove it, simply replace it with an empty string like this : 
$str = str_replace("\n", "", $str);

//Also, if you want it to be reflected in your HTML you should replace the \n with <BR>.
$str=nl2br($str);

//Or
$str = str_replace("\n", "<BR>", $str);

以上是关于PHP 从字符串中删除换行符的主要内容,如果未能解决你的问题,请参考以下文章