title: Replace Multiple Spaces and Newlines with only one space in PHP
body: <p>I have a string with multiple newlines.</p>
  
  <p>The String:</p>
  
  <pre><code>This is         a dummy text.               I need              
  
  
  
  
  to                                      format
  this.
  </code></pre>
  
  <p>Desired Output: </p>
  
  <pre><code>This is a dummy text. I need to format this.
  </code></pre>
  
  <p>I'm using this:</p>
  
  <pre><code>$replacer  = array("\r\n", "\n", "\r", "\t", "  ");
  $string = str_replace($replacer, "", $string);
  </code></pre>
  
  <p>But it is not working as desired/required. Some of the words don't have spaces between them.</p>
  
  <p>Actually I need to convert the string with all the words separated by single spaces.</p>