title: Line break issue when displaying file contents in html text area - javascript PHP
body: <p>I am trying to display the contents of a text file into a text area element but the am having issues with a line break being displayed as '\n' instead of actually doing it. </p>
  
  <pre><code>&lt;textarea id = "textArea" name = "textArea" data-ng-model="note.text"&gt;&lt;/textarea&gt;
  </code></pre>
  
  <p>javascript to add the text to text area element</p>
  
  <pre><code>var $promise=$http.post("http://localhost/PHP/findNotes.php", data); //send data to user.php
  $promise.then(function(msg){
  
         document.getElementById("textArea").value = msg.data;
  
        });
  </code></pre>
  
  <p>PHP file to get file contents</p>
  
  <pre><code>$note=json_decode(file_get_contents('php://input'));  //get note 
  $noteId = ($note-&gt;noteId);  
  $userId = ($note-&gt;userId); 
  
  $filename = 'file://localhost/Library/WebServer/Documents/Notes/'.$userId.'/'.$noteId.'.txt';
  
  if (file_exists($filename))   
  {  
    $file = fopen($filename, "r");  
    while (!feof($file))   
    {  
      $display = fgets($file, filesize($filename));  
      echo $display; 
    }  
    fclose($file);  
  }   
  else   
  {  
    echo "Error occurred!";  
  } 
  </code></pre>
  
  <p>When reading the file with content </p>
  
  <pre><code>line1\nline2\n\nline4
  </code></pre>
  
  <p>the exact same thing is shown in the text area</p>
  
  <p>However if the file contents is applied directly to the textarea in the js code then the linebreaks work perfectly.</p>
  
  <p>so if the JS is changed to</p>
  
  <pre><code>document.getElementById("textArea").value ="line1\nline2\n\nline4";
  </code></pre>
  
  <p>then the output in the text area is correctly:</p>
  
  <pre><code>line1
  line2
  
  line4
  </code></pre>
  
  <p>Would appreciate any help, it seems as if it's a problem with the format of the text received from PHP? 
  Thanks in advance</p>