title: How do I convert line breaks to \n
body: <p>I have a return string from a db.</p>
  
  <p>The return string must be formatted in javascript.</p>
  
  <pre><code>&lt;?php
      $db = "this is a line
             this is a new line";
  ?&gt;
  </code></pre>
  
  <p>How would I convert the above to:</p>
  
  <pre><code>&lt;?php $db = "this is a line \n this is a new line"; ?&gt;
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>&lt;script&gt;
      var jdb = &lt;?php echo $db; ?&gt;
  &lt;/script&gt;
  </code></pre>