Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

change return key to <br>

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

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?

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

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... ;)
New php-forum User
New php-forum User
Posts: 7
Joined: Tue Apr 15, 2003 4:52 pm
Location: Stockholm, Sweden

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

This is more politicaly correct. :wink:

Code: Select all
$yourstring = ereg_replace("\n","<br />",$yourstring);
New php-forum User
New php-forum User
Posts: 38
Joined: Fri Apr 04, 2003 2:44 pm
Location: Canada

Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.