Welcome to WebmasterWorld Guest from 54.196.208.6

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

creating <br /> from textarea

     
9:01 pm on Oct 26, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 21, 2002
posts: 1541
votes: 0


If I have a textarea and a complete the form like:

99 Main Street
Springfield
New York

And I store it in the database.
When I pull it into a variable to be echoed, how do I create the <br />'s i.e. to stop it looking like:

99 Main Street Springfield New York

is it something to do with /n?
10:13 pm on Oct 26, 2012 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

joined:Apr 9, 2011
posts:12702
votes: 244


Can't you just echo the <br /> itself? Add it to the end of each string. (Or possibly "<br \/>". I forget.)

:: detour to random page to confirm that that's what I did in recently created navigation footer ::

The difference between \n and and <br> is the same as in ordinary raw html: one affects what you see in the code. The other affects what the user sees.
10:18 pm on Oct 26, 2012 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12533
votes: 0


You can use the nl2br function:
[php.net...]