I want to keep only numbers and remove all characters from a variable.
For example:
input: +012-(34).56.(ASD)+:"{}|78*9
output: 0123456789
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
With Zend_Filter_Digits
Example with static call through Zend_Filter:
Example with Digits instance
Internally, the filter will use
preg_replaceto process the input string. Depending on if the Regex Engine is compiled with UTF8 and Unicode enabled, one of these patterns will be used:[^0-9]– Filter if Unicode is disabled[^[:digit:]]– Filter for the value with mbstring[\p{^N}]– Filter for the value without mbstringSee http://framework.zend.com/svn/framework/standard/trunk/library/Zend/Filter/Digits.php