So let’s say I have an option page that will set $threshold as '1', '2', '3', '4', or '5'
I’ve got a form that submits/redirects differently based on that threshold (right now the threshold is set to three only, not changeable, so one, two, and three go to PAGE ONE and do FUNCTION ONE, while four and five got to PAGE TWO and do FUNCTION TWO.
I want people to be able to set their own threshold.
currently I have:
if($foo == 'five' || $foo == 'four' || $foo == 'three'){
//DO ALL THIS CRAZY STUFF
} else {
//DO ALL THIS OTHER STUFF
}
what I WANT is basically a threshold wrapped around that:
if($threshold == '5'){
if($foo == 'five'){
//DO ALL THIS CRAZY STUFF
} else {
//DO ALL THIS OTHER STUFF
}
} else if ($threshold =='4'){
if($foo =='five' || $foo == 'four')
if($foo == ‘five’){
//DO ALL THIS CRAZY STUFF
} else {
//DO ALL THIS OTHER STUFF
}
}
etc. for 3, 2, and 1 as well.
Is there an easy way to do that? Like should I set the if/or statements as variables? like:
if($threshold == '5'){ $var = "$foo =='five'" }
else if($threshold == '4'){ $var = "$foo =='five' || $foo == 'four'" }
then do
if($var){
//DO ALL THIS CRAZY STUFF
} else {
//DO ALL THIS OTHER STUFF
}
??
I’m not quite sure the ‘best approach’ to this :/
I’m not really sure if, for different
$thresholdnumbers and$foocombinations, you have different functions for each of them, or if you just want to know if$foois located within the specified$threshold. I guess the latter is your goal: