Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 删除段落中的换行符_Php_String - Fatal编程技术网

Php 删除段落中的换行符

Php 删除段落中的换行符,php,string,Php,String,我希望能够删除回程中断,只保留1次,我尝试了: $lesujet = "testing ..."; $letexts = "a bunch of text there is a return break here another return break as you see"; mail("myemail@gmail.com",$lesujet,$letexts,$headers); 它不起作用。 我希望它能输出如上所示格式的文本,相反,这是它返回的内容(每个返回间隔加倍,这非常

我希望能够删除回程中断,只保留1次,我尝试了:

$lesujet = "testing ...";
$letexts = "a bunch of text   

there is a return break here

another return break as you see";

mail("myemail@gmail.com",$lesujet,$letexts,$headers);
它不起作用。 我希望它能输出如上所示格式的文本,相反,这是它返回的内容(每个返回间隔加倍,这非常烦人):

使用如下修剪功能:

    a bunch of text   


    there is a return break here


    another return break as you see
使用如下修剪功能:

    a bunch of text   


    there is a return break here


    another return break as you see
试试这个:

$letexts = trim($letexts);
试试这个:

$letexts = trim($letexts);

$letexts=preg\u replace(“~[\r\n]~”,“,$letexts)
$letexts=preg\u replace(“~[\r\n]~”,“,$letexts)
通常,当某些东西“不起作用”时,提供更多信息会很有帮助。您希望得到什么输出?你得到的结果是什么?对不起,Michael,信息添加了无问题:)有时人们会在认为海报没有很好地描述问题时否决问题。这里可能就是这种情况,但是你的编辑已经澄清了很多事情。一般来说,当某些事情“不起作用”时,提供更多信息是很有帮助的。你希望得到什么样的结果?你得到的结果是什么?对不起,Michael,信息添加了无问题:)有时人们会在认为海报没有很好地描述问题时否决问题。这里可能是这样,但是你的编辑已经澄清了很多事情。不起作用,奇怪的是它们都不起作用,我对str replace很熟悉,应该起作用。无论如何,要显示$letexts包含的\n和\r?不起作用,奇怪的是它们都不起作用,我熟悉str replace,这本应该起作用。是否仍要显示$letexts包含的\n和\r?