Numeric Values
Moderator: General Moderators
-
php_wiz_kid
- Forum Contributor
- Posts: 181
- Joined: Tue Jun 24, 2003 7:33 pm
Numeric Values
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.
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
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
Last edited by m3rajk on Sat Aug 02, 2003 3:20 pm, edited 1 time in total.
-
php_wiz_kid
- Forum Contributor
- Posts: 181
- Joined: Tue Jun 24, 2003 7:33 pm
-
php_wiz_kid
- Forum Contributor
- Posts: 181
- Joined: Tue Jun 24, 2003 7:33 pm
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
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