Last active
June 4, 2018 14:33
-
-
Save finagin/296b55f36da543f78a6210265e0476dc to your computer and use it in GitHub Desktop.
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 | |
define('EOL', PHP_SAPI == 'cli' ? PHP_EOL : '<br>'); | |
$min = 1; | |
$max = 10; | |
$range = [$min, $max]; | |
foreach (range(...$range) as $i) { | |
$line = ''; | |
foreach (range(...$range) as $j) { | |
$line .= false // | |
|| in_array($i, $range) // Borders x | |
|| in_array($j, $range) // Borders y | |
|| $i == $j // Main diagonal | |
|| abs($max - $i + 1) == $j // Anti-diagonal | |
? '#' : ' '; | |
} | |
echo $line.EOL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment