June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
28
Task/Rock-paper-scissors/PHP/rock-paper-scissors.php
Normal file
28
Task/Rock-paper-scissors/PHP/rock-paper-scissors.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
echo "<h1>" . "Choose: ROCK - PAPER - SCISSORS" . "</h1>";
|
||||
echo "<h2>";
|
||||
echo "";
|
||||
|
||||
$player = strtoupper( $_GET["moves"] );
|
||||
$wins = [
|
||||
'ROCK' => 'SCISSORS',
|
||||
'PAPER' => 'ROCK',
|
||||
'SCISSORS' => 'PAPER'
|
||||
];
|
||||
$a_i = array_rand($wins);
|
||||
echo "<br>";
|
||||
echo "Player chooses " . "<i style=\"color:blue\">" . $player . "</i>";
|
||||
echo "<br>";
|
||||
echo "<br>" . "A.I chooses " . "<i style=\"color:red\">" . $a_i . "</i>";
|
||||
|
||||
$results = "";
|
||||
if ($player == $a_i){
|
||||
$results = "Draw";
|
||||
} else if($wins[$a_i] == $player ){
|
||||
$results = "A.I wins";
|
||||
} else {
|
||||
$results = "Player wins";
|
||||
}
|
||||
|
||||
echo "<br>" . $results;
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue