[Solved] Pyramid asterisk in PHP


You might want to check out some of the string functions:

<?php

for ($i = 5; $i > 0; $i--) {
        echo str_repeat(' ', 5 - $i).str_repeat('*',$i).PHP_EOL;
}

for ($i = 5; $i > 0; $i--) {
        echo str_pad(str_repeat('*',$i),5,' ',STR_PAD_LEFT).PHP_EOL;
}

This runs on the command line, like so:

php filename.php

0

solved Pyramid asterisk in PHP