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

c# - IMAP GMAIL getting folder list problem -

PHP proxy to get XML: problem with URL arguments -