Stooney Posted January 24, 2008 Share Posted January 24, 2008 I have a textarea input which is output later. To retain the linebreaks when outputting, are 'pre' tags good to use? Or is there a better (or more updated) method to use? Quote Link to comment https://forums.phpfreaks.com/topic/87504-textarea-line-breaks/ Share on other sites More sharing options...
rajivgonsalves Posted January 24, 2008 Share Posted January 24, 2008 you can use the function nl2br http://php.net/nl2br Quote Link to comment https://forums.phpfreaks.com/topic/87504-textarea-line-breaks/#findComment-447584 Share on other sites More sharing options...
ziv Posted January 24, 2008 Share Posted January 24, 2008 pre tag is good for any pre-formated data (plain text) but if you want to convert it to simple html, you can use the nl2br() function. <?php $str = 'this is text with new line'; echo $str; //this is text with new line echo nl2br($str); //this is text<br />with new line ?> Quote Link to comment https://forums.phpfreaks.com/topic/87504-textarea-line-breaks/#findComment-447585 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.