According to ncyoung.com, you can use the following piece of code to convert line-breaks into the <br> tag in PHP:
$str = preg_replace("/\n/","\n<BR>",$str);
Another way to do it is just use the <PRE> tag to enclose the string :
echo "<pre>$str</pre>";
