Cless Posted August 17, 2007 Share Posted August 17, 2007 Hi. Is there a certain way to 'auto-magically' add line breaks when enter is pressed? That way, you don't need to say something like.. This is a message.<br /><br /> Messages are fun! Normally, if you type... This is a message. Messages are fun! It would turn out like this. This is a message. Messages are fun! Thanks! Link to comment https://forums.phpfreaks.com/topic/65472-solved-auto-linebreaks/ Share on other sites More sharing options...
chocopi Posted August 17, 2007 Share Posted August 17, 2007 Im not sure I understand what your on about but i think you might want to check out nl2br ~ Chocopi Link to comment https://forums.phpfreaks.com/topic/65472-solved-auto-linebreaks/#findComment-326899 Share on other sites More sharing options...
Cless Posted August 17, 2007 Author Share Posted August 17, 2007 Lol. Like, when you're posting a new topic here. They made it so < br /> codes are added automatically when you press enter. If you don't have that code, you need to type < br /> for a new line. :S Link to comment https://forums.phpfreaks.com/topic/65472-solved-auto-linebreaks/#findComment-326902 Share on other sites More sharing options...
chocopi Posted August 17, 2007 Share Posted August 17, 2007 im assuming you mean that you insert data into a table using a textarea, if that is the case then before you echo the data use nl2br ~ Chocopi Link to comment https://forums.phpfreaks.com/topic/65472-solved-auto-linebreaks/#findComment-326906 Share on other sites More sharing options...
Cless Posted August 17, 2007 Author Share Posted August 17, 2007 I see... how exactly would you do that? Like this? echo nl2br($Message); Thanks. Link to comment https://forums.phpfreaks.com/topic/65472-solved-auto-linebreaks/#findComment-326913 Share on other sites More sharing options...
wildteen88 Posted August 17, 2007 Share Posted August 17, 2007 I see... how exactly would you do that? Like this? echo nl2br($Message); Thanks. Yes that is correct. However if you inserting text submitted from a form into a database don't use nl2br in that sense. Only use nl2br when you get the content out of the database. If you use nl2br when you insert text into a database you may find PHP will duplicate the newlines. Link to comment https://forums.phpfreaks.com/topic/65472-solved-auto-linebreaks/#findComment-326920 Share on other sites More sharing options...
Cless Posted August 17, 2007 Author Share Posted August 17, 2007 Ah. I see. Thanks. I'll go try it out. Thanks! It worked! Woot! Link to comment https://forums.phpfreaks.com/topic/65472-solved-auto-linebreaks/#findComment-326922 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.