Forum Moderators: coopster

Message Too Old, No Replies

how can i remove a line space entered in a texarea

         

laura2k

11:38 pm on Jun 2, 2004 (gmt 0)



hi there,

i have a form with a textarea field and when a user enters details i use the $_POST['address'] to get the value of it, but the problem is that if the user enters line spaces (by pressing enter) then i get the spaces in my variable. Can someone please tell me how i can remove all line spaces and replace it with <br> instead?

thanx

coopster

11:51 pm on Jun 2, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Are you saying you want to insert HTML line breaks before all newlines in a string [php.net]?

laura2k

11:57 pm on Jun 2, 2004 (gmt 0)



no what i am saying is that, when a user fills in the address field and i capture the value of that field by using $_POST['address'] but if the user entered for example:

123 Testing Road
Testing
Testing

i want to know how i can remove all the line spaces and put <br> there instead so it reads:

123 Testing Road<br>Testing<br>Testing

coopster

12:07 am on Jun 3, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Follow the link provided (see the examples listed for explanation/clarity), it seems you are stating the same thing. Either that, or it is very late in the day and I need a break ;)

laura2k

12:27 am on Jun 3, 2004 (gmt 0)



problem with that is that i still get a line break but this time with a <br /> but thats not exactly what i am trying to do. at the moment using nl2br($_POST['address']) i get:

123 Testing Road
<br />
Testing
<br />
Testing

as apposed to getting the original which is:

123 Testing Road
Testing
Testing

but what i really need to do is remove all those line breaks and put everything on one line so it looks like this:

123 Testing Road <br />Testing <br />Testing

Thanx

laura2k

12:53 am on Jun 3, 2004 (gmt 0)



i've figure it out using the ereg_replace function

thanx

DevlshOne

7:51 pm on Jun 8, 2004 (gmt 0)

10+ Year Member



Tried php's nl2br function? It should read all "new line"s and convert them to "<br>"s.

WhosAWhata

5:07 pm on Jun 9, 2004 (gmt 0)

10+ Year Member



that was recommended in the second and fourth posts
you should read the thread before you make a post, just to make sure you aren't repeating anyone else. for future reference,
but glad to see a "new user" helping out

DevlshOne

6:24 pm on Jun 9, 2004 (gmt 0)

10+ Year Member



Whoops.. read the thread, did not follow the link. :)