Skip to content

Commit

Permalink
Update Dicky.php
Browse files Browse the repository at this point in the history
av
  • Loading branch information
dickykumay authored Oct 19, 2021
1 parent e2aa0f3 commit 2f9af98
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Dicky.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,43 @@

<table class="tic-tac-toe" cellpadding="0" cellspacing="0">
<tbody>

<?php
$lastRow = 0;
for ($i = 1; $i <= 9; $i++) {
$row = ceil($i / 3);

if ($row !== $lastRow) {
$lastRow = $row;

if ($i > 1) {
echo "</tr>";
}

echo "<tr class='row-{$row}'>";
}

$additionalClass = '';

if ($i == 2 || $i == 8) {
$additionalClass = 'vertical-border';
}
else if ($i == 4 || $i == 6) {
$additionalClass = 'horizontal-border';
}
else if ($i == 5) {
$additionalClass = 'center-border';
}
?>

<td class="cell-<?= $i ?> <?= $additionalClass ?>">
<?php if (getCell($i) === 'x'): ?>
X
<?php elseif (getCell($i) === 'o'): ?>
O
<?php else: ?>
<input type="radio" name="cell" value="<?= $i ?>" onclick="enableButton()"/>
<?php endif; ?>
</td>

<?php } ?>

0 comments on commit 2f9af98

Please sign in to comment.