Skip to content

Instantly share code, notes, and snippets.

@susanBuck
Created October 9, 2019 23:04
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 susanBuck/044a2eb2e944fd63c2e7aebc857e2f83 to your computer and use it in GitHub Desktop.
Save susanBuck/044a2eb2e944fd63c2e7aebc857e2f83 to your computer and use it in GitHub Desktop.
Tac tac toe example for Shawna
<?php require 'index-controller-sb.php'; ?>
<!doctype html>
<html lang='en'>
<head>
<title>Tic Tac Toe</title>
<meta charset='utf-8'>
</head>
<body>
<h1>Tic Tac Toe</h1>
<table border=1>
<?php foreach ($board as $key => $vector) { ?>
<!-- If we're at a1, b1 or c1, it's the start of a new row -->
<?php if (in_array($key, ['a1', 'b1', 'c1'])) { ?>
<tr>
<?php } ?>
<td>
<?php echo $vector; ?>
</td>
<!-- If we're at a3, b3 or c3, it's the end of a row -->
<?php if (in_array($key, ['a3', 'b3', 'c3'])) { ?>
</tr>
<?php } ?>
<?php } ?>
</table>
<?php if (is_null($results['winner'])) { ?>
No winner; it’s a draw.
<?php } else { ?>
<p>The winner is <?php echo $results['winner']; ?> (<?php echo $results['line']; ?>)
<?php } ?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment