ktsirig Posted April 12, 2006 Share Posted April 12, 2006 Hello all,my problem is the following: I have a page where the user enters some data, let's say :string1 = 'AGREHREHRHREHRE';string2 = 'WEFEWGEWGEGEWGEGEGWG'; These data I use in another page, so I use the "<pre>" tag to display what the user has entered. The problem arrives when the user writes something like EWGEGEW EFGEGEW EGRGREGRE RGVFVDSVDSThis string, when I pass it into a variable, it is stored with newlines. I don't want to make any substitution of the newlines, as I want to preserve the spaces in the next page, and display the user's sequence as entered and not with 3 <br>'s, because there were 3 spaces in the original string...any ideas? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 12, 2006 Share Posted April 12, 2006 Your question doesn't make any sense.If I enter a string into a form and that string contains spaces, there is nothing in PHP that would automaticly convert the spaces into the "<br>" tags. If I were to enter a string that contains the newline character and you echo it without surrounding the string with the '<pre></pre>' tags, then it looks like the newline character have been converted to spaces, but if you do a "show source" you will see they are still there. This is a side affect of how HTML renders strings. If you want to display the lines as entered, you can use the nl2br() function when you echo it. This function will add the "<br />" tag before each newline character.Please post either a better explanation of your problem and/or code that illustrates it.Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.