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]