In C/C++, you can have something like Case(something) case A, B, C, D : Do Function 1; case E, F, G, H : Do Function 2;
But, you can't do that in PHP. so, is there any other efficient way to do this without using IF statement? Thanks in advance.
Why would you want to use an IF statement?
No, I said some other way which doesn't use IF statement. Since php CASE statement doesn't support the feature I mention.
You're aware of the switch () function? It seems similar to your CASE function in C++
switch ($x) { case 0: some action; break;
case 1: some action; break;
default: some action; }
This way, you avoid the IF_ELSE and IF_ELSEIF_ELSE statments. I'm not sure, but you could probably try to loop it in a for statement or a while statement as well, if the testing for cases are consecutive.
i use
switch (...) {
case 1: // instead of case 1,2 case 2: ... break;
case 3: break; }
ditto
and can have multiple nestings