$foo=1;
function someFunction(){
if($foo==0){ //-------Will test, won't execute
bar();
}elseif($foo==1){ //--Will test, and execute
baz();
}elseif($foo==2){ //--Doesn't test
qux();
}elseif($foo==3){ //--Doesn't test
quux();
}else{ //-------------Doesn't test
death();
} //------------------The program will skip down to here.
}
Let’s say that baz() changes the value of $foo and it is different every time. I want my code to keep testing the elseif/else statements after the first one and run those if they are true.
I don’t want to run the whole function again, (i.e. I don’t care if $foo = 0 or 1). I’m looking for something like “continue;”. Anyways please let me know if this is possible. Thanks. 🙂
EDIT** My code is actually way more complicated than this. I was just putting some code down for the sake of theory. All I want is the script to keep testing where it usually wouldn’t.
If I’m understanding correctly, you want to do each consecutive
elseif, regardless of whether previousif/elseifs matched, but you also want some code to run if none of theif/elseifs match. In this case, you can set a flag$matchedto be set totrueif one of them matches and useifs instead.If you also want to be able to skip to the end, use
goto(but see this first):