Created
July 17, 2016 15:25
-
-
Save ad3n/58889ab2f3da1803f3034a617dbe6bcf to your computer and use it in GitHub Desktop.
Segitiga Plain
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
<?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