Thursday, 15 September 2011

Trying to filter out non-numeric values with regex in php -


Thank you for taking the time to read my question. I am trying to filter non-numeric values ​​from a variable in php. I have tried this:

$ output = "76gg7hg67ku6"; Preg_replace ('/ \ d /', $ output, $ level) resonance $ level;

Instead of Preg, the level should be set to 767676, but when I echo the level, it does not have anything in it. Your help is greatly appreciated.

You must use \ D to change the non-digit < / P>

  $ re = "/ \\ D /"; $ Str = "76gg7hg67ku6"; $ Subst = ""; $ Result = preg_replace ($ re, $ subst, $ str);  

Bus fighter:

  \ D matches any character which does not have a number [^ 0- 9] \ d matches the digit [0-9]  


No comments:

Post a Comment