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? Link to comment https://forums.phpfreaks.com/topic/122124-probably-a-simple-question/ 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 Link to comment https://forums.phpfreaks.com/topic/122124-probably-a-simple-question/#findComment-630521 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. Link to comment https://forums.phpfreaks.com/topic/122124-probably-a-simple-question/#findComment-630598 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.