How to check if a *string* has only numbers...
| From: | Rafael Soares | Date: | Wed, 17 Nov 2004 00:36:04 +0000 |
| Subject: | How to check if a *string* has only numbers... | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-24982@lists.php.net to get a copy of this message | ||
Hello people!!!
I would like to check if a string contains only numbers, I really cant
realize how to do it.
I tried is_int(), but it dont work because the variable is a string (I used
gettype() to check it) and is_int() returns NULL
It is to validate some data in a form. The variable Im trying to test is
the result of this script:
$data = $_POST[data]; // something like 123.456.789
$dataParts = explode($data);
//these are the variable I have to check:
$dataP1 = $dataParts[0];
$dataP2 = $dataParts[1];
$dataP3 = $dataParts[3];
gettype($dataP1), gettype($dataP2) and gettype($dataP3) return string
gettype($dataParts) returns array
Thanks in advance.
Rafael Soares - AgênciaM
Fone: +55 11 4616-1394