The Code Developer

PHP program to print alphabet pattern N

In this article write a PHP program to print alphabet pattern N. This Program first takes the numbers of rows and then prints pattern using nested for loops.

PHP program to print alphabet pattern N

<?php
echo "<pre>";
for ($row = 0; $row < 11; $row++) {
    for ($col = 0; $col <= 12; $col++) {
        if ($col == 0 OR $col == 12 OR ($row == $col - 1)) {
            echo "*";
        } else {
            echo "&nbsp;";
        }
    }
    echo "<br/>";
}
echo "</pre>";
?>

Output:

alphabet pattern N