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

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -