$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
答案 0 :(得分:1)
使用修剪函数trim,如下所示:
$letexts = trim($letexts);
答案 1 :(得分:1)
试试这个:
$letexts = preg_replace("/\r\n\s*\r\n/", "\r\n", $letexts);
答案 2 :(得分:1)
$letexts = preg_replace('~[\r\n]~','',$letexts)