Created
September 15, 2018 16:09
-
-
Save Florencelg/6d789c7756c03087c0440098f4b29498 to your computer and use it in GitHub Desktop.
PHP procédural - Les conditions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$weapons = ['fists', 'whip', 'gun']; | |
$opponentWeapon = $weapons[rand(0,2)]; // Cela permet de choisir une arme de manière aléatoire. | |
$indyWeapon = $weapons; | |
if ($opponentWeapon == $weapons[0]){ | |
$indyWeapon = $weapons [2]; | |
}elseif ($opponentWeapon == $weapons [1]){ | |
$indyWeapon = $weapons [0]; | |
}else{ | |
$indyWeapon = $weapons [1]; | |
} | |
echo $indyWeapon; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment