title: Keep only digits in a string
body: <p>Here is the <code>regex</code> which is removing characters and keeping only digits in a string. This working fine. Please read below examples which are not working for only one case - that is if user enters "4 four" so it can be converted to 44.   </p>
  
  <pre><code> //1
      //with out character 
      $amount = "44"; 
      $cleanedamount = preg_replace ( '/[^0-9]+/', '',  $amount);
      var_dump($cleanedamount);
      //2
      //digit prior
      $amount1 = "44usd"; 
      $cleanedamount1 = preg_replace ( '/[^0-9]+/', '',  $amount1);
      var_dump($cleanedamount1);
  
      //3
      //digit later
      $amount2 = "usd44"; 
      $cleanedamount2 = preg_replace ( '/[^0-9]+/', '',  $amount2);
      var_dump($cleanedamount2);
  
      //4
      //how to convert "4 four" to "44"
  </code></pre>
  
  <p><a href="http://ideone.com/ynug9h" rel="nofollow">Demo</a> </p>