I don’t want to repeat the same statements over and over again.
What is the best way to do this?
<?php
if ($a = '3'){
statement 1;
statement 2;
statement 3;
}else if ($a = '2'){
statement 1;
statement 2;
}else if ($a = '1'){
statement 1;
}
?>
To avoid repetitions, you can code:
Or, that is the same:
Also, take a look to Switch statement
Quoting php doc:
For your code: