Page 1 of 1

change return key to <br>

Posted: Thu Apr 03, 2003 2:51 pm
by mynmonic
I know the function nl2br() which is convert newline to <br>, which newline stand for '\n' here.

Now I want to convert every 'Enter' I press here in this textarea into <br> after I submit, and then write them into a file or db something. How can I perform this conversion?


Thanks

Posted: Tue Apr 15, 2003 4:56 pm
by Osaou
Use this:

Code: Select all

$yourstring = str_replace("\r\n","<br />",$yourstring);

It should do the trick... ;)

Posted: Wed Apr 16, 2003 4:08 am
by Oromian
This is more politicaly correct. :wink:

Code: Select all

$yourstring = ereg_replace("\n","<br />",$yourstring);