title: Php clean double dash with str_replace
body: <p>I'm using php to clean out names to be used in a url slug:, where $title might look like this:  "This is the Title" or "This is the Title &amp; Subtitle"</p>
  
  <p>Those above examples I want to change to "this-is-the-title" and "this-is-the-title-subtitle", respectively.  So, I made this code....</p>
  
  <pre><code>&lt;?php 
  $input1 = str_replace(" ","-",strtolower($title)); 
  $output1 = preg_replace('/[^A-Za-z0-9-]/', '', $input1); 
  $output2 = str_replace("--","-",$output1); 
  echo $output2; 
  ?&gt;
  </code></pre>
  
  <p>It's working great, cleaning out all the non-alpha numeric, replacing spaces with dashes and making everything lower case.</p>
  
  <p>However, in some instances, it's returning the double dash ("Title &amp; More" turns to ("title--more").  It should be "title-more".  I know why the double dash is there, but I can't seem to clean it out.</p>
  
  <p>I put in the line of code for $output2, but it doesn't seem to be working for some reason.  After lots of trial and error, I'm at a loss.</p>
  
  <p>Thanks...</p>