ceylon
03-20-2009, 09:25 PM
is there a function similiar to all the is_ ones that would validate if a variable is a negative or positive integer? I tried the following for the same effect, but no luck with it:
"bds":4,
if(strpos(strval($v[bds]),'-') === false) { echo "is negative"; }
steelaz
03-20-2009, 09:36 PM
Is there a reason you can't use:
if ($v[bds] < 0) { echo "is negative"; }
timgolding
03-20-2009, 10:44 PM
You could use the is_int to test that its an integer and then just check its less than 0
if(is_int($v[bds]) && $v[bds]<0)) { echo "nagative integer"; }
but is_int does validate if a variable is a negative or positive integer
benjam1nrk
03-21-2009, 05:05 PM
How about:
if(is_int(abs($v[bds])) && $v[bds]<0)) { echo "nagative integer"; }
Take the absolute value of the input first to determine if it is an integer...