0) { # user wants to guess a letter $guess = $_GET["guess"]; if (preg_match("/$guess/", $available)) { # not already guessed before; make the guess $available = preg_replace("/$guess/", " ", $available); setcookie("LAB5_SOLUTION_available", $available); if (!preg_match("/$guess/", $word)) { # an incorrect guess $guesses--; setcookie("LAB5_SOLUTION_guesses", $guesses); } } } # produce current clue string based on available letters $clue = preg_replace("/[$available]/", "?", $word); ?> Hangman

Hangman Step by Step

hangman
( guesses remaining)
0 && $clue != $word) ? "" : "disabled=\"disabled\"" ?> />
0) { ?>
Congratulations! You win!
Game over! You lost!
HINT: The word is: ""
The letters available are: ""