Created
October 9, 2019 23:04
-
-
Save susanBuck/044a2eb2e944fd63c2e7aebc857e2f83 to your computer and use it in GitHub Desktop.
Tac tac toe example for Shawna
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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