PHP Program To Print Reverse Pyramid Pattern

In this article write a PHP Program To Print Reverse Pyramid pattern. This Program first takes the numbers of rows and then prints pattern using nested for loops.

Read Also : PHP Program To Print Pyramid

PHP Program To Print Reverse Pyramid Pattern using * and for loop.

<?php
echo "<pre>";
$n = 10;
for ($i = 10; $i > 0; $i--) {
    for ($j = $n - $i; $j > 0; $j--)
        echo "&nbsp;&nbsp;";
    for ($j = 2 * $i - 1; $j > 0; $j--)
        echo ("&nbsp;*");
    echo "<br>";
}
echo "</pre>";
?>

Output:

reverse pyramid pattern

Leave A Reply

Your email address will not be published.