SHARE
TWEET

Untitled

a guest Oct 13th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $pfc = ['pierre', 'feuille', 'ciseau'];
  4. $userChoice = readline("pierre, feuille ou ciseaux ? ");
  5.  
  6. if (!in_array($userChoice, $pfc)){
  7.     echo "tu dois choisir pierre, feuille ou ciseaux\n";
  8.     exit();
  9. }
  10. echo "tu peux jouer\n";
  11.  
  12. $pfc = ['pierre', 'feuille', 'ciseau'];
  13. $ordiChoice = $pfc[rand(0,2)];
  14. echo "Ton adversaire a choisi : $ordiChoice\n";
  15. if ($userChoice == $ordiChoice) {
  16.     echo "egalité\n";
  17.     exit();
  18. }
  19.  
  20. switch ($userChoice) {
  21.     case 'pierre':
  22.         if ($ordiChoice == 'ciseaux') {
  23.             echo "Gagné\n";
  24.         } else {
  25.             echo "Perdu\n";
  26.         }
  27.         break;
  28.     case 'feuille':
  29.         if ($ordiChoice == 'pierre') {
  30.             echo "Gagné\n";
  31.         } else {
  32.             echo "Perdu\n";
  33.         }
  34.         break;
  35.     case 'ciseaux':
  36.         if ($ordiChoice == 'feuille') {
  37.             echo "Gagné\n";
  38.         } else {
  39.             echo "Perdu\n";
  40.         }
  41.         break;
  42.     default:
  43.         break;
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top