Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replacing \r\n with <br />

Tags:

html

forms

php

Basically i'm trying to set something where a user enters some text into a textarea (and they press their enter key to add new lines) and then it takes the value from that text area and mails it out in the message of a new email to a specified contact.

All the mailing functionality works, but I need to be able to automatically add a new line when the user presses enter in the textarea.

Using this to get the info from the previous page/form and replace the \r\n:

$BREAKINGNEWS=$_POST['BREAKINGNEWS'];
$NEWS = str_replace("\r\n","<br />",$BREAKINGNEWS);

Then just adding $NEWS into the code to mail it out.

Doesn't seem to work though, just puts it on 1 line and doesn't replace the \r\n!

Any help is most appreciated :)

like image 751
Noah Goodrich Avatar asked Feb 23 '23 00:02

Noah Goodrich


1 Answers

Just use the nl2br built in

like image 92
Quentin Avatar answered Mar 04 '23 08:03

Quentin