change return key to <br>

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

mynmonic
New php-forum User
New php-forum User
Posts: 18
Joined: Tue Nov 26, 2002 3:35 am
Location: Hong Kong
Contact:

change return key to <br>

Postby mynmonic » Thu Apr 03, 2003 2:51 pm

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

Osaou
New php-forum User
New php-forum User
Posts: 7
Joined: Tue Apr 15, 2003 4:52 pm
Location: Stockholm, Sweden
Contact:

Postby Osaou » Tue Apr 15, 2003 4:56 pm

Use this:

Code: Select all

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

It should do the trick... ;)

Oromian
New php-forum User
New php-forum User
Posts: 38
Joined: Fri Apr 04, 2003 2:44 pm
Location: Canada
Contact:

Postby Oromian » Wed Apr 16, 2003 4:08 am

This is more politicaly correct. :wink:

Code: Select all

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


Return to “PHP coding => General”

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 3 guests