Write a program to draw the half pyramid pattern in php language of stars using the for loop
ADVERTISEMENTS
Write a program to draw the half pyramid pattern in the php language of stars using the for loop. Here, you will learn how to draw the half pyramid pattern in the php language of stars using the for loop.
Take an example to print this half pyramid pattern of the stars through a php program:
<?php
// Write a program to draw the half pyramid pattern
// in the PHP language of stars using the for loop
// It's the number of rows
$r = 10;
// It's the driver code to
// print the half pyramid pattern
for ($i = 1; $i <= $r; ++$i) {
for ($j = 1; $j <= $i; ++$j)
echo "* ";
echo "\n";
}
?>
Output
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * * * * *