/** * Checks if the input contains a normalized or localized number * * @param string $input Localized number string * @param array $options Options: locale. See {@link setOptions()} for details. * @return boolean Returns true if a number was found */ public static function isNumber($input, array $options = array()) { if (!self::_getUniCodeSupport()) { trigger_error("Sorry, your PCRE extension does not support UTF8 which is needed for the I18N core", E_USER_NOTICE); } $options = self::_checkOptions($options) + self::$_options; // Get correct signs for this locale $symbols = Zend_Locale_Data::getList($options['locale'], 'symbols'); $regexs = Zend_Locale_Format::_getRegexForType('decimalnumber', $options); $regexs = array_merge($regexs, Zend_Locale_Format::_getRegexForType('scientificnumber', $options)); if (!empty($input) && $input[0] == $symbols['decimal']) { $input = 0 . $input; } foreach ($regexs as $regex) { preg_match($regex, $input, $found); if (isset($found[0])) { return true; } } return false; }
/** * Checks if the input contains a normalized or localized number * * @param string $input Localized number string * @param array $options Options: locale. See {@link setOptions()} for details. * @return boolean Returns true if a number was found */ public static function isNumber($input, array $options = array()) { $options = self::_checkOptions($options) + self::$_options; // Get correct signs for this locale $symbols = Zend_Locale_Data::getList($options['locale'], 'symbols'); $regexs = Zend_Locale_Format::_getRegexForType('decimalnumber', $options); $regexs = array_merge($regexs, Zend_Locale_Format::_getRegexForType('scientificnumber', $options)); if (!empty($input) && $input[0] == $symbols['decimal']) { $input = 0 . $input; } foreach ($regexs as $regex) { preg_match($regex, $input, $found); if (isset($found[0])) { return true; } } return false; }