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? 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 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 ?> Link to comment https://forums.phpfreaks.com/topic/87504-textarea-line-breaks/#findComment-447585 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.