php替换换行符和字符而不是展开文本

时间:2014-07-03 20:58:43

标签: php

替换功能是删除所有等号,但它不会解开文本。

$文本

I will be doing a Training next Thursday morning @ 1am in Gal=
laway. Please let me know if you plan on attending and I =
will send out another reminder next week prior to that time. This is predo=
minately for new users (or those who would like a refresher course). I wil=
l touch base briefly on registrations and would be happy to stay after to r=
eview any more advanced booking issues or questions you might have.

Facilities Coordinator

PHP

$text = str_replace("=\n", "", $text);

2 个答案:

答案 0 :(得分:1)

尝试使用PHP_EOL来查找换行符:

str_replace( "=" . PHP_EOL, "", $text )

PHP_EOL常量保存服务器上使用的换行符。

答案 1 :(得分:0)

首先标准化您的行结尾

$text = preg_replace("/\r\n?/s", '\n', $text );

对于单行您可以试试这个,请注意" s" - 和" m"修饰符 - 似乎在regx测试器中工作我试过但不是100%确定它会起作用。

$text = preg_replace("/=$\r?\n?/ms", "", $text);

如果PHP_EOL的内容是在服务器上创建的,那么PHP_EOL将会起作用,但是如果它在一个不同的文件系统上创建的文件,如果内存为我提供了正确的帮助,它将无法帮助我。