0
$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,我尝试过:

 $letexts = str_replace("\r","",$letexts);
 $letexts = str_replace("\n","",$letexts);

它不起作用。我期望它输出格式如您在上面看到的文本,而不是它返回的内容(每个返回中断加倍,这很烦人):

    a bunch of text   


    there is a return break here


    another return break as you see
4

3 回答 3

1

像这样使用修剪功能 修剪

$letexts = trim($letexts);
于 2012-08-04T03:35:27.857 回答
1

尝试这个:

$letexts = preg_replace("/\r\n\s*\r\n/", "\r\n", $letexts);
于 2012-08-04T03:35:53.480 回答
1

$letexts = preg_replace('~[\r\n]~','',$letexts)

于 2012-08-04T03:52:13.160 回答