Page 1 of 1
Array Of Numbers
Posted: Sun Feb 19, 2006 2:17 pm
by icesolid
What would be the best way of determining if a number equals 150 or 159 or any number in between 150-159?
Would an array be the best way or would it be easier with an if statement?
Posted: Sun Feb 19, 2006 2:29 pm
by feyd
you mean the sum of the values?
array_sum()
or do you mean the number of values?
count()
No
Posted: Sun Feb 19, 2006 2:39 pm
by icesolid
No I want to determine a variables value, if its equal to something.
EX:
if($var = anything in between 150 and 159 or equal to 150 or 159) {
do this
} else {
do this
}
Posted: Sun Feb 19, 2006 2:44 pm
by feyd
Posted: Sun Feb 19, 2006 2:45 pm
by shiznatix
Code: Select all
foreach ($array_of_numbers as $val)
{
if ($val > 149 && $val < 160)
{
//you have a match! run with it baby, ya!
}
}
edit: once again, I am beat by feyd