I have got an if/elseif statement, both with the exact same code, but I want to trigger them depending on the condition. I have got the exact same code duplicated in the if statement aswell as the elseif statement.
$x = 10;
$y = 20;
if($x <= $y){
// some code
}
elseif($x >= $y){
$x = $y;
$y = $x;
// same code as if
}
I am curious if there is a way that I do not have to duplicate my code in both the if statement aswell as the elseif statement.
Aucun commentaire:
Enregistrer un commentaire