In this tutorial, we will discuss about PHP Full Pyramid pattern program
Here, we can see three type of pyramid pattern displays using nested for loop in PHP using stars
Program 1
Here, we are providing a inverted star pyramid pattern using for loop in PHP programming language
<?php //Star Pyramid Size //PHP pyramid patterns $rows = 7;//Rows of Pyramid for($i=$rows; $i>=1; --$i){ for($space=0 ;$space<=$rows-$i; ++$space) echo (" ");//print initial spaces for($j=$i; $j<=2*$i -1 ;$j++) print ("* ");//print stars echo "\n";//move to next line } ?>
When the above code is executed, it produces the following result
Program 2
Here, we are providing a star pyramid pattern using for loop in PHP programming language
<?php //PHP Star Pyramid pattern $size = 6; for($i=1;$i<=$size;$i++){ for($j=1;$j<=$i; $j++){ echo("*");//print star } echo "\n";//move to next line } for($i=$size; $i>=1; $i--){ for($j=1; $j<=$i; $j++){ echo("*");//print star } echo "\n"; //move to next line } ?>
When the above code is executed, it produces the following result
Program 3
<?php //Star Pyramid Size //PHP pyramid patterns $rows = 6;//Rows of Pyramid for($i=1; $i<=$rows; ++$i){ for($space=$rows; $space>$i; --$space) echo (" ");//print initial spaces for($j=1; $j<=$i ;$j++) { print ("* ");//print stars } echo "\n";//move to next line } ?>
Suggested for you
Java program to print star pyramid pattern
C program to print star pyramid pattern
C++ program to print star pyramid pattern
Python program to print star pyramid pattern
Triangle star pattern in Java language
Triangle star pattern in C language
Triangle star pattern in C++ language
Nested for loop in Java language
Nested for loop in C++ language
Nested for loop in Python language
PHP Star Triangle pattern program In this tutorial, we will discuss about PHP Star Triangle…
5 methods to add two numbers in Java In this tutorial, we will discuss the…
Python full Pyramid star pattern program In this tutorial, we will discuss the concept of…
Write a function or method to convert C into F -Entered by the user In…
How to write a function or method to convert Celsius into Fahrenheit In this tutorial,…
Program for Celsius into Fahrenheit conversion In this tutorial, we will discuss the concept of…