SWITCH Function

In its standard form, the SWITCH function provides alternations depending on the set condition, very similar to IF. The main advantage seems to be that the structure is easier to analyze.

Equivalence by IF

As I mentioned, the equivalent can be achieved using the IF function.

SWITCH with AND or OR clause

Of course, if it is necessary to meet two cumulative conditions (AND), $var > 10 && $var <= 20 will be set. For the switch with the alternative fulfillment of the condition (OR), the example below can also be used.

Author: Ovidiu.S

I am quite passionate about this professional area as if I know something - no matter how little - I want to share it with others.

Leave a Reply