Skip to content

Instantly share code, notes, and snippets.

@ahmadrosid
Last active October 8, 2021 07:59
Show Gist options
  • Save ahmadrosid/f68646531f390e978653b9f79e242fbc to your computer and use it in GitHub Desktop.
Save ahmadrosid/f68646531f390e978653b9f79e242fbc to your computer and use it in GitHub Desktop.
<?php
function colorized($var)
{
return "\e[0;30;42m$var\e[0m";
}
$firstRowIndex = 3;
$secondRowIndex = 2;
for ($i = 1; $i <= 64; $i++) {
for ($j = 1; $j <= 3; $j++) {
if ($j == $firstRowIndex ) {
echo " $i ";
} else {
echo colorized(" $i ");
}
$i++;
}
$i++;
echo " $i ";
$firstRowIndex++;
$firstRowIndex = $firstRowIndex == 4 ? 1 : $firstRowIndex;
for ($k = 1; $k <= 3; $k++) {
if ($k == $secondRowIndex ) {
echo " $i ";
} else {
echo colorized(" $i ");
}
$i++;
}
echo " $i\n";
$secondRowIndex++;
$secondRowIndex = $secondRowIndex == 4 ? 1 : $secondRowIndex;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment