Skip to content

Instantly share code, notes, and snippets.

@Florencelg
Created September 15, 2018 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Florencelg/6d789c7756c03087c0440098f4b29498 to your computer and use it in GitHub Desktop.
Save Florencelg/6d789c7756c03087c0440098f4b29498 to your computer and use it in GitHub Desktop.
PHP procédural - Les conditions
<?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