Re: problem with intval and !=
| From: | Jordan S. Jones | Date: | Thu, 23 Oct 2003 16:36:43 +0000 |
| Subject: | Re: problem with intval and != | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-167312@lists.php.net to get a copy of this message | ||
Cesar,
You can take a look into is_numeric () (http://www.php.net/is_numeric). It will tell you whether the value is a number or a numeric string, but it will also return true if the value is a float. However, at that point you know your working with the right type of variable.
Jordan S. Jones
Cesar Cordovez wrote:
Sorry, typo, this is what I meant, !is_integer("12thisisnotanumber") retuns true. but also, is_integer("12") return false. therefore, is_integer(12) return true. So, how can I check if what ever the user writes is an integer or not, knowing that he will write it in a string field. Any how, I solved the problem with preg_match("/^([0-9]+)$/", $value) Thanks for your help, list!!!! =) Robert Cummings wrote:-- I am nothing but a poor boy. Please Donate.. https://www.paypal.com/xclick/business=list%40racistnames.com&item_name=Jordan+S.+Jones&no_note=1&tax=0¤cy_code=USDOn Thu, 2003-10-23 at 11:41, Cesar Cordovez wrote:Because is_integer("12thisisnotanumber") retuns true.Not for me it doesn't. Returns false. Prolly because it's a string. Even the following returns false for me:is_integer("12")Cheers, Rob.