title: PHP Regex allow only a-z A-Z 1-9 and replace spaces with underscore
body: <p>So i need <code>preg_replace()</code> to </p>
  
  <ul>
  <li>remove all characters but a-z A-Z 1-9 </li>
  <li>replace spaces with single underscore <code>\s+</code></li>
  <li>if there's multiple underscores in string it need to be replaced with
  single one <code>[_]+</code></li>
  </ul>
  
  <p>Code</p>
  
  <pre><code>$str = "Hz!!    zÒ142______23 4";
  $str = preg_replace('/[^a-zA-Z0-9][_]+\s+/', '_', $str);
  echo $str; //Outputs: Hz_z142_23_4
  </code></pre>
  
  <p><strong>Edit</strong> i'd like to do it with single preg_replace</p>