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

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Restarting Supervisor and effect on FlaskSocketIO -

php - Mongodb connectivity error -