Example 1 — Shrink the row with the outer loop
Start $row at 5 and stop at 1. The inner loop echoes 1 through $row.
<?php
$rows = 5;
for ($row = $rows; $row >= 1; $row--) {
for ($n = 1; $n <= $row; $n++) {
echo $n;
}
echo PHP_EOL;
} How It Works
$row--makes each later line one digit shorter.- The inner
foralways restarts at 1, so every row begins with 1. echo $nstays on the row.echo PHP_EOLstarts the next one.

