Page 1 of 1
Numeric Values
Posted: Sat Aug 02, 2003 3:13 pm
by php_wiz_kid
Is there a function that allows me to pass a variable into it and it checks to see if the variable is numeric only, or do I have to do a ereg() type thing. I made a function that replaces the ereg() so it isn't as time consuming to program to check for multiple unwanted characters, but a numeric only function would be much faster.
Posted: Sat Aug 02, 2003 3:16 pm
by m3rajk
go to php.net.
i think there's is_int and is_double
one for floating points and one for whole...
i needed them when i was trying to find out if a number is evern or odd... they don't have that, so i did is_double($a/2) and true was odd and false was even (which whould tell you which is which)
note: is_double, is_float and _is_real are the same thing (two are aliases for is_double...)
note 2: is_int is_integer and is_long are the same (in this case aliases of is_long...)
note 3: for the hell of it i checked my book. you might wanna look at is_numeric is_scalar and is_string
Posted: Sat Aug 02, 2003 3:20 pm
by php_wiz_kid
Hey thanks, there's also is_numeric()
Posted: Sat Aug 02, 2003 3:21 pm
by m3rajk
np
Posted: Sat Aug 02, 2003 3:21 pm
by php_wiz_kid
is_int() was more of what I was looking for though
Posted: Sat Aug 02, 2003 3:25 pm
by m3rajk
heh. i remembered them becasue i was trying to find out if something was odd. it's only a double if it's not .0 when over 2
since i knew i was dealing with whole numbers it made it easy to check.
although i got half a mind to send them something that looks at the last number of a number (treating it as a string) to see if it's [0,2,4,6,8] and then sending it into php.net calling it is_even