title: "Unexpected EOF" : How do I remove all newlines from php code?
body: <p>I have a php script that is reading a file in (file_get_contents). I want to replace all newlines with br's, and strip out all other characters. However, I am getting an error when interpreting the contents into a javascript variable.</p>
  
  <p>I think the guilty party is the "^Z" character, but I don't know how to get rid of it. The "^M" is a git character, and I believe the "^Z" is actually part of the string itself.</p>
  
  <p>How would I strip this character out in php?</p>
  
  <p><img src="https://i.stack.imgur.com/mO2Fj.png" alt="enter image description here"></p>
  
  <hr>
  
  <p>Okay, my question was wrong before, so I have updated it with new content.</p>
  
  <p>How do I ensure that all newlines are removed from a php string? This string is read in with file_get_contents, then javascript is dynamically created with the contents of the file. The "\n" is replaced with "NEW," and the "\r" is replaced with "".</p>
  
  <p>However, I am getting an "Unexpected EOF" error, and when I copy the string and paste it into the console, something is giving me newlines. How do I make sure that ALL newlines (whitespace for that matter) is trimmed out?</p>
  
  <p><code>trim()</code>
  <code>str_replace</code>
  <code>preg_replace</code></p>
  
  <p>Have all been used, any help is greatly appreciated!</p>
  
  <p><img src="https://i.stack.imgur.com/cHntO.png" alt="SyntaxError: Unexpected EOF"></p>