Re: How to check if a *string* has only numbers...
| From: | user at domain dot invalid | Date: | Fri, 19 Nov 2004 11:37:01 +0000 |
| Subject: | Re: How to check if a *string* has only numbers... | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-24999@lists.php.net to get a copy of this message | ||
Hi,
Have you tried regular expressions ? try them, they might do the trick
Rui Francisco
Rafael Soares wrote:
Hello people!!! I would like to check if a string contains only numbers, I really can’t realize how to do it. I tried is_int(), but it don’t 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 I’m 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