Re: regular expressions ?
| From: | Zouari Fourat | Date: | Thu, 27 Jan 2005 16:09:58 +0000 |
| Subject: | Re: regular expressions ? | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-207500@lists.php.net to get a copy of this message | ||
to Marek Kilimajer :
$i='5.';
if (($i>=1) && ($i<=20) && ($i==(int)$i))
echo 'yes';
// yes
:'(
On Thu, 27 Jan 2005 16:52:20 +0100, Marek Kilimajer <lists@kilimajer.net> wrote:
> Zouari Fourat wrote:
> > here's the problem :
> > my user MUST input only digits between 1 and 20
> > doing a is_numeric and some comparaison can be bypassed by inputing :
> >
> > .5
> > or
> > 0.5
> > or
> > 5.1
> > or
> > 0.3
> > or
> > .01
> > ...
> > ...
> >
> > so i thought that the smartest way is to use regex
> >
>
> if( $i >= 1 && $i <= 20 && $i == (int)$i) ...
>