How to make the number pyramid program in php?

Today, We want to share with you number pyramid program in php.In this post we will show you number pattern programs in php, hear for star pattern in php we will give you demo and example for implement.In this post, we will learn about PHP Nested Forloop – Exercises Pyramid Program Solution with an example.

PHP programs for printing pyramid patterns

Number pattern pyramids in PHP can be printed using for and foreach loop. There are a some of patterns in pyramid pattern. Some of them are display here.

Example 1: Number Pattern

 

Results

1 
2 2 
3 3 3 
4 4 4 4 
5 5 5 5 5 

Example 2: Character Pattern

 

Results

A 
B B 
C C C 
D D D D 
E E E E E 

Example 3: Continuous Character pattern

 

Results

A 
B C 
D E F 
G H I J 
K L M N O 

PHP Program To Print Pyramid

PHP program to Print Pyramid Pattern using * and loop.

";
$space = 10;
for ($no = 0; $no <= 10; $no++) {
    
    for ($k = 0; $k < $space; $k++) {
        echo " ";
    }
    for ($x = 0; $x < 2 * $no - 1; $x++) {
        echo "*";
    }
    
    $space--;
    echo "
"; } echo "

“;
?>

I hope you get an idea about alphabet pattern programs in php.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment