Jump to content


Form output is one straight line from textarea

form line breaks

  • Please log in to reply
2 replies to this topic

#1 kent12



  • New Members
  • Pip
  • 1 posts

Posted 23 January 2014 - 10:22 PM

Form output:

Description: vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv


textarea coding on input form:


<textarea rows="10" name="description" cols="70"><?php echo set_value('description'); ?></textarea><br>


coding on output:


<td class="dt2 dt0"><?php echo $this->lang->line('Description');?>:</td>
                                  <td class="dt2"><?php echo nl2br($project->description); ?></td>


How can I get the line breaks in the output?


Your help would be appreciated.



#2 Ch0cu3r


    Advanced Member

  • Moderators
  • 3,418 posts

Posted 23 January 2014 - 10:36 PM


How can I get the line breaks in the output?

Your code should already do this. That is what nl2br does


It wont, however insert line breaks where continuous text hits the boundaries of a textarea. For example your series of v's will appear as the following in the textarea


There is no line break being inserted for the second line, it is the browser forcing the text to next line. The text will be submitted as one long line (exactly as it was typed). A line break will only be submitted when the user presses the enter key.


If you want limit text to exactly 70 chars per line, then use wordwrap before nl2br

Edited by Ch0cu3r, 23 January 2014 - 10:42 PM.

#3 dalecosp


    Advanced Member

  • Members
  • PipPipPip
  • 341 posts
  • LocationMissouri

Posted 23 January 2014 - 10:37 PM

Well, you assume that the user will be giving you some sort of help with this, then?

Because it could be they type it in without ever hitting return.

I suppose you could look at wordwrap()...
"God doesn't play dice" --- Albert Einstein
"Perl is hardly a paragon of beautiful syntax." --- Weedpacket

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users