With Zend_Filter_Digits
Returns the value of the string $, deleting all characters except numbers.
Example with a static call through Zend_Filter:
echo Zend_Filter::filterStatic('abc-123-def-456', 'Digits');
Example with an instance of numbers
$digits = new Zend_Filter_Digits; echo $digits->filter('abc-123-def-456');
Inside the filter will use preg_replace to process the input string. Depending on whether the Regex Engine is compiled with UTF8 and Unicode enabled, one of these templates will be used:
[^0-9] - Filter if Unicode is disabled.[^[:digit:]] - Filter for a value using mbstring[\p{^N}] - Filter for a value without mbstring
See http://framework.zend.com/svn/framework/standard/trunk/library/Zend/Filter/Digits.php
source share