PHP Program to Draw a Pattern



In this post I am going to describe the very basic PHP Program which tell us how draw Pattern. Patten are the one of the most important and basic program which are very frequently asked in interviews and these programs are very easy to make. These program generally make two for loop outer for loop are there for Columns and inner for loop are for Rows and in between we have break line (br) statement. Now let have a look at our desired pattern in the pattern we have 7 columns and the rows get decremented by 1 star(* ) in every new columns so we will make outer loop to run for 7 times (form $i=7 to $i=1) a and inner loop in such a way that in 1st column it will run 7 times, for 2nd column it will run 6 times and so on.
<?php
for($i=7;$i>=1;$i--){ //for loop for columns
	for($j=$i;$j>=1;$j--){ //for loop for Rows
		echo "* ";
	}
	echo"<br>"; //<br> statement for new line
	
} ?>

Program Output:

Stay tuned for the PHP Magento, WordPress and Magento2 latest tutorial and updates, Hope you enjoyed reading, if you need the professional Magento Development / PHP we can help you, just Click on the Link and send me your requirements.

Please Like the Post on Facebook or Google+.