well.  sure, is_numeric() will work, but the point of the
exercise is to try and determine if a number is numeric
without actually calling is_numeric() or regexps.

personally, i think that regexps are swiss-army knives,
they can do almost anything -- i use them all the time,
although it took me a few months to fully understand them
and get over regexp-heebie-jeebies of my own.

> -----Original Message-----
> From: daniel james [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, August 28, 2001 6:42 PM
> To: scott [gts]; php
> Subject: RE: [PHP] is_numeric for php3
> 
> 
> Ahhh, in that context, with is_integer(), i think
> you're partially right.  however, i looked it up, and
> is_numeric() will work fine.
> 
> http://www.php.net/manual/en/function.is-numeric.php
> 
> btw-- as for the regexps, none for me, thanks ;) 
> those things give me the heebie-jeebies.
> 
> --- "scott [gts]" <[EMAIL PROTECTED]> wrote:
> > i think he's asking for a numeric test, not an
> > integer test.
> > 
> > your example looks like it should fail "3.50" (for
> > example),
> > even though "3.50" is a perfectly valid numeric
> > value.
> > 
> > personally, i think you should just use regexps. ;-)
> > 
> > i tried to write a little is_num() type function,
> > but i kept
> > getting caught on split();  it seems that split()
> > converts
> > everything to string, no matter what.  so if you try
> > to split
> > on the decimal point of 45.67 ... you get two
> > strings, "45" and "67"
> > not 45 and 67, so subsequent is_integer() calls fail
> > 
> > (since is_integer() checks the *type* of the
> > variable,
> > not the *value* -- very important to keep in mind)
> > 
> > here's what i came up with... perhaps it will be of
> > some
> > help to you (even though it doesnt work)
> > 
> > 
> > function is_num($number) {
> > 
> >   // $x contains number, $y contains any decimal
> > value
> >   list ($x, $y) = split("\.", $number);
> > 
> >   // if there's no decimal value
> >   if ( empty($y) ) {
> >     return is_int($x);
> >   }
> >   else {
> >     return ( is_int($x) && is_int($y) );
> >   }
> > 
> > }
> > 
> > 
> > > -----Original Message-----
> > > From: daniel james [mailto:[EMAIL PROTECTED]]
> > > Subject: Re: [PHP] is_numeric for php3
> > > 
> > > do you mean, as in,
> > > 
> > > if !is_integer($var) {
> > > print("$var is not an integer");
> > > }
> > > 
> > 
> > -- 
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > To contact the list administrators, e-mail:
> > [EMAIL PROTECTED]
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with Yahoo! Messenger
> http://phonecard.yahoo.com/
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to