Re: check for variable value but need 0 to be good ?
| From: | Jon Parise | Date: | Tue, 01 Aug 2000 18:59:21 +0000 |
| Subject: | Re: check for variable value but need 0 to be good ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-9516@lists.php.net to get a copy of this message | ||
On Tue, Aug 01, 2000 at 12:03:22PM -0500, Adrian Smith wrote:
> I am checking a field to make sure the user has entered a value but
> in the situation I have the user can and may need to pick 0 in the
> drop down which is then treated as no value when checked for a
> value, is there a way I can get it to treat 0 only has a value and
> still check for a value as normal ?
Try checking the length of the string:
if ((strlen(trim($my_var)) > 1) && is_int($my_var)) {
foo;
}
--
Jon Parise (jon@csh.rit.edu) . Rochester Inst. of Technology
http://www.csh.rit.edu/~jon/ : Computer Science House
Member