Inersha
08-15-2008, 12:17 PM
I am trying to make a small script that gives an specific output given a certain combination of two input values. I am currently doing it with if, elseif and else statements which works fine up to a point, but I am wondering if there is a better and cleaner way to go about things.
Basically, I want PHP to give a certain output depending on the country of the visitor and a number that they enter.
For example, the script is a little like this...
if ($country == "country" && $money < 50) {
echo 'something';
}
elseif ($country == "country" && $money=> 50 && $money <= 50000) // this will not work - too many &&s i think. {
echo 'something else';
}
The script goes on for a few more elseif statements, but I guess the biggest problem if giving an output if a person is from a certain country and the money value is BETWEEN two numbers.
What would be the best solution?
Basically, I want PHP to give a certain output depending on the country of the visitor and a number that they enter.
For example, the script is a little like this...
if ($country == "country" && $money < 50) {
echo 'something';
}
elseif ($country == "country" && $money=> 50 && $money <= 50000) // this will not work - too many &&s i think. {
echo 'something else';
}
The script goes on for a few more elseif statements, but I guess the biggest problem if giving an output if a person is from a certain country and the money value is BETWEEN two numbers.
What would be the best solution?