PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
icesolid
Forum Regular
Posts: 502 Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY
Post
by icesolid » Sun Feb 19, 2006 2:17 pm
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?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Feb 19, 2006 2:29 pm
you mean the sum of the values?
array_sum()
or do you mean the number of values?
count()
icesolid
Forum Regular
Posts: 502 Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY
Post
by icesolid » Sun Feb 19, 2006 2:39 pm
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
}
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Feb 19, 2006 2:44 pm
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Sun Feb 19, 2006 2:45 pm
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