Summary
Make a chain of if
s and elseif
s for a variable that can have several different values.
Situation
A variable can take on different values in different conditions.
Action
- $variable = initial value;
- if (test) {
- $variable = something;
- }
- elseif (another test) {
- $variable = something else;
- }
- ...
- else {
- $variable = something else again;
- }
- Do something with $variable;
Where referenced