title: How to remove line breaks (no characters!) from the string?
body: <p>This might appear to be a dupe, but rest assured it isn't - I have searched both SO as well as the rest of the web for an answer to my problem and ended up finding the same insufficient "solutions" over and over. Anyhow, here it goes:</p>
  
  <p>I'm saving user input from a textarea to a MySQL database (within a WordPress environment, but that ought not to matter to this problem, I believe). It is later retrieved from the DB to be shown to Admins in the backend of the site. The problem occurs when users submit text with line breaks (i.e. hit the Enter key).</p>
  
  <p>A sample string might look like this:</p>
  
  <pre><code>Dear friends, I just wanted so Hello. How are you guys? I'm fine, thanks!
  
  Greetings,
  Bill
  </code></pre>
  
  <p>There are no end of line characters ("\n", "\r", or the like) in the string.</p>
  
  <p>I am using <code>nl2br()</code> on it to generate HTML output, but that's not enough. The result then is:</p>
  
  <pre><code>Dear friends, I just wanted so Hello. How are you guys? I'm fine, thanks!&lt;br /&gt;
  &lt;br /&gt;
  Greetings,&lt;br /&gt;
  Bill
  </code></pre>
  
  <p>Which, as far as I understand it, is the expected <code>nl2br()</code> result, as that inserts the tags and isn't supposed to replace the line-breaks in the first place?</p>
  
  <p>However the format I need would be this:</p>
  
  <pre><code>Dear friends, I just wanted so Hello. How are you guys? I'm fine, thanks!&lt;br /&gt;&lt;br /&gt;Greetings,&lt;br /&gt;Bill
  </code></pre>
  
  <p>If the string had EOL characters such as "\n" in it, I'd hit it with either <code>str_replace()</code> or <code>preg_replace()</code> and be done with it, but I have no clue what needle to feed either of those functions if there ain't no characters there in the first place.</p>
  
  <p>I can manually access the relevant field in the DB, hit Backspace for every linebreak and what I later on want to do with the string works. So I know I need the above format.</p>