Greg Beaver wrote:

http://www.php.net/is_numeric

is the function you are looking for. No need for fancy regexps.

The OP is looking for an integer, but is_numeric() will return true for float values and also for numbers in scientific notation. So "12.3" and "12E3" will be TRUE.


The original $number != intval($number) should work for detecting bad input.

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to