I'm trying to replace carriage returns with a line break in PHP so that my site moderators don't have to type
every time they want to add a new line when typing an email from my site. I've tried several different methods to replace the line breaks but none have worked. The methods that I have tried are:
preg_replace('/\r\n?/', "<br />", $str);
eregi_replace(char(13), "<br />", $str);
str_replace("\r\n", "<br />", $str);
str_replace("\n", "<br />", $str);
and the nl2br function.
I've looked for the answer on Google for about half an hour and haven't found anything. Can anyone help?
", $str); or $str = nl2br($str); – Summoner Jul 30 '12 at 14:22
", $str); – JustSomeGuy Jul 30 '12 at 14:28