Last active
May 23, 2016 17:01
-
-
Save tonythere/a0e1f34c9664f6dae04c3e17cf826e1c 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 | |
$m = 5; | |
$n = 4; | |
$col_span = 4; | |
$row_span = 4; | |
const star = 'O'; | |
const space = ' '; | |
$records = []; | |
$total_horizontal_chars = $n * ($row_span - 1) + 1; | |
$total_vertical_chars = $m * ($col_span - 1) + 1; | |
for ($row = 0; $row < $total_vertical_chars; $row++) { | |
$record = ''; | |
for ($col = 0; $col < $total_horizontal_chars; $col++) { | |
$thisChar = space; | |
if ($row % ($row_span - 1) == 0 || $col % ($col_span - 1) == 0) { | |
$thisChar = star; | |
} | |
$record = $record . $thisChar; | |
} | |
$records[] = $record; | |
} | |
$result = implode("\n", $records); | |
?> | |
<pre><?= $result; ?></pre> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment