using nl2br function

nl2br — Inserts HTML line breaks before all newlines in a string

  1. <html>  
  2.  <body>  
  3. n style="color: #000000;"><?php
  4. style="color: #007700;">echo nl2br("foo isn't\n bar");
  5. ?>
  6.  </body>   
  7. </html>  

The above example will output:

foo isn't<br />
 bar
eXTReMe Tracker