Re: variable type - conversion/checking
| From: | Maciek Sokolewicz | Date: | Sat, 16 Mar 2013 17:52:58 +0000 |
| Subject: | Re: variable type - conversion/checking | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-320613@lists.php.net to get a copy of this message | ||
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 georgAll 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 }