Printing pyromid pattern using php

GOCOURSE

Printing pyromid pattern 1

Program:

<?php
$rows = 5;

for ($i = 1; $i <= $rows; $i++) {
    for ($j = 1; $j <= $rows - $i; $j++) {
        echo "  ";
    }
    for ($k = 1; $k <= 2 * $i - 1; $k++) {
        echo "* ";
    }
    echo "\n";
}
?>

Output:

        * 
      * * * 
    * * * * * 
  * * * * * * * 
* * * * * * * * *

Tags
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send