Re: variable type - conversion/checking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have tried to find a way to check if a character string is possible to
test whether it is convertible to an intger !

any suggestion ?

BR georg

All responses in this thread have been very nice; but you could also try a much simpler 2-step check:

1. is_numeric
2. if true > check if there's a decimal character in the string:

if(is_numeric($str) && false === strpos('.', $str)) {
   // it's an int for sure
} else {
   // might be a number, but it's definitly not an int
}

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux