Skip to content

Instantly share code, notes, and snippets.

@ad3n
Created July 17, 2016 15:25
Show Gist options
  • Save ad3n/58889ab2f3da1803f3034a617dbe6bcf to your computer and use it in GitHub Desktop.
Save ad3n/58889ab2f3da1803f3034a617dbe6bcf to your computer and use it in GitHub Desktop.
Segitiga Plain
<?php
$limit = 7;
for ($i = 1; $i < $limit; $i++) {
for ($j = ($limit - $i); $j >= 0; $j--) {
echo ' ';
}
$flag = true;
$temp = $i;
while ($flag) {
if (0 !== $temp && -1 !== $temp) {
echo abs($temp);
}
$temp--;
if ($temp + 1 === -1 * $i) {
$flag = false;
}
}
echo PHP_EOL;
}
for ($i = $limit; $i > 0; $i--) {
for ($j = ($limit - $i); $j >= 0; $j--) {
echo ' ';
}
$flag = true;
$temp = $i;
while ($flag) {
if (0 !== $temp && -1 !== $temp) {
echo abs($temp);
}
$temp--;
if ($temp + 1 === -1 * $i) {
$flag = false;
}
}
echo PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment