Replace all line break in a string with <br /> tag in javascript
<blockquote>
  <p><strong>Exact duplicate: <a href="http://stackoverflow.com/questions/784313/read-line-break-in-a-string-with-javascript">Read line break in a string with javascript</a></strong></p>
</blockquote>

<p><hr /></p>

<p>Does anyone know how I can read the line break from a value with javascript and replace all the line breank with br tag?</p>

<p>Example:</p>

<p>A Variable passed from php as below:</p>

<pre><code>  "This is man.

     Man like dog.
     Man like to drink.

     Man is the king."
</code></pre>

<p>I would like my result to look something like this after the Javascript convert it... </p>

<pre><code>  "This is man&lt;br /&gt;&lt;br /&gt;Man like dog.&lt;br /&gt;Man like to drink.&lt;br /&gt;&lt;br /&gt;Man is the king.";
</code></pre>
