PHP preg_replace replacing line break
This thing worked for me.
preg_replace("/\r\n\r\n|\r\r|\n\n/", "<br />", $element);
This should work too:
// char(32) is whitespace
// For CR
$element = strtr($element, chr(13), chr(32));
// For LF
$element = strtr($element, chr(10), chr(32));
It's a hack, but you can do something like this:
$email_body_string = preg_replace("/\=\r\n$/", "", $email_body_string);
The replacement says find a line that ends with an equals sign and has the standard carriage return and line feed characters afterwards. Replace those characters with nothing ("") and the equals sign will disappear. The line below it will be pulled up to join the first line.
Now, this implies that you will never have a line that ends with an equals sign, which is a risk. If you want to do it one better, check the line length where the wrap (with the equals sign) appears. It's usually about 73 characters in from the beginning of the line. Then you could say:
if (strlen(equals sign) == 73)
$email_body_string = preg_replace("/\=\r\n$/", "", $email_body_string);
That preg looks a bit complicated. And then you have ^ in the beginning as not A-Z... or linefeed. So you don't want to replace linefeed?
How about
$newelement = preg_replace("/[\n\r]/", "", $element);
or
$newelement = preg_replace("/[^A-Za-z ]/", "", $element);
\s also matches linefeed (\n).