PHP Program To Print Inverted Number Pyramid Pattern

In this article write a PHP Program To Print Inverted Number 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 Inverted Number Pyramid Pattern using numbers

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

Output:

Print Inverted Number Pyramid Pattern

Leave A Reply

Your email address will not be published.