php - Preserve Line Breaks From TextArea When Writing To MySQL -


i'm using textarea enable users input comments. however, if users enters new lines, new lines don't appear when outputted. there way make line breaks stay.

any idea how preserve line breaks?

two solutions this:

  1. php function nl2br():

    e.g.,

    echo nl2br("this\r\nis\n\ra\nstring\r");  // output this<br /> is<br /> a<br /> string<br /> 
  2. wrap input in <pre></pre> tags.

    see: w3c wiki - html/elements/pre


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -