$text = 'blah<br /><br />blah';
$text = preg_replace('#<br />#', "\n", $text);
When I view it in the browser it does enter the double line breaks. However, when I try to send it to my email address via the mail() function it only outputs one line break.
Does anyone know what’s the reason for this? And how to make it work?
And I am trying to send plain text, not html.
Content-Type: text/plain; charset="utf-8"
Try using
PHP_EOLinstead, for a cross-platform compatible solution, although"\n"should be 99% fine. Also, I’d suggest str_replace() instead of preg_replace(), parsing with regex (though as simple as this) is somewhat slower (*),(*) I’m waiting for critics about this