I’ve got a textbox that I am using to do calculations with based on the code entered into it. This code will have either a prefix or a suffix added to it. My problem is that in one code, the prefix and suffix rules will clash and cause both actions to happen, when I only want the prefix action to happen. Here’s the code:
//get suffix and prefix from input box
$suffix = $inputbox[strlen($inputbox)-1];
$prefix = $inputbox[0];
if($inputbox!="" && $suffix=="L" or $suffix=="P" or $suffix="Y" or $suffix=="T")
{
//do this
}
if($inputbox!="" && $inputbox=="NT")
{
//do that
}
With the code as it is, the script is doing both, because the input box is NT and it also has a suffix of T. What I want is to ignore the first rule, or put an operator in the first rule to say that it should only run if suffix is T and prefix is not N.
I know there is a simple way to do it, but it’s almost 1am and I want to finish this before I retire to my bed!
So switch the order and use an
else. Also, you have a redundant rule, which I’ve removed. Also, your&&has a higher precedence than yourors; but it’s also unnecessary. You’ve also mixed in an assignment with the condition. (Maybe get some rest?)