Created
January 6, 2012 13:18
-
-
Save oliveiraev/1570554 to your computer and use it in GitHub Desktop.
Solução ao desafio proposto em http://wbruno.com.br/blog/2012/01/04/primeiro-desafio-wbruno-de-php/
This file contains hidden or 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
<!DOCTYPE HTML> | |
<html lang="pt-Br"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
<style> | |
table { | |
border: none; | |
} | |
td { | |
padding: 7px; | |
text-align: center; | |
} | |
.highlight { | |
background: #000; | |
color: #f00; | |
} | |
</style> | |
</head> | |
<body> | |
<table><?php | |
foreach (range(0, 80) as $n) { | |
$c = $n % 9; | |
$l = floor($n / 9); | |
$css = null; | |
$line_begin = null; | |
$line_end = null; | |
$cell_value = '-'; | |
if (!$c) $line_begin = "\n\t\t<tr>"; | |
if ($c == $l or $c + $l == 8) $css = 'class="highlight"'; | |
if ($c == 4 or $l == 4) $cell_value = '+'; | |
if ($c == 8) $line_end = "\n\t\t</tr>"; | |
$cell = "\n\t\t\t<td {$css}>{$cell_value}</td>"; | |
echo $line_begin, $cell, $line_end; | |
} | |
?> | |
</table> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
P.S.: Veja a marcação gerada ;)