Thursday, January 28, 2016

PYRAMID IN PHP: Form a Pyramid Using Numbers in PHP

PHP loops execute a block of code a specified number of times. There are four (4) types of loops in PHP. The for loop, foreach loop, do while loop and the while loop. In this tutorial, we will be focusing on the while loop which I often used in creating iterations to save code and memory space.

I created another PHP Code to dsiplay a pyramid out of numbers. This program uses two (2) looping statement. In my example, I did used the while and for loop to accomplished this. It is called a nested loop, a loop inside a loop.

If you want to change the limit of rows in the pyramid, just change the value 30 to whatever you desire.

Try Pyramid in PHP here.

PHP Code Pyramid

echo $i1;
echo "<br>";

Output Pyramid

Thank you for visiting and hope this helps you. Feel free to leave a comment below for any questions. I got some other articles related to php and mysql here in my blog. Watch out for more upcoming tutorials related to blogging and programming. Good day! ^_^

PYRAMID IN PHP: Form a Pyramid Using Numbers in PHP

No comments:

Post a Comment