Preserve Line Breaks From TextArea When Writing To MySQL

The Solution to Preserve Line Breaks From TextArea When Writing To MySQL is


Two solutions for this:

  1. PHP function nl2br():

    e.g.,

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

    See: W3C Wiki - HTML/Elements/pre

~ Answered on 2011-02-19 05:20:18


Most Viewed Questions: