waynew Posted August 31, 2008 Share Posted August 31, 2008 Let's just say you have a textarea and the user typing into that textarea hits enter, going to a new line. How can I allow these break lines to be outputted? Quote Link to comment Share on other sites More sharing options...
gaza165 Posted August 31, 2008 Share Posted August 31, 2008 On output you need to use... nl2br($string) that will output linebreaks e.g This is my first sentence <br/> This is my second sentence Hope this is what you are looking for. Garry Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted August 31, 2008 Share Posted August 31, 2008 To clarify, it won't 'output linebreaks' - the new lines are outputted anyway, it is just that any amount of whitespace in HTML is treated as one space. If you were not outputting HTML and were, for example, writing to a file, the new lines would be present. To have a new line in a webpage, you must use the br tag. The function nl2br() converts the new line character to a br tag. 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.