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 have 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 6 columns and the rows get incremented by 1 star(* ) in every new columns so we will make outer loop to run for 6 times(form $i=1 to $i=6) a and inner loop in such a way that in 1st column it will run 1 times, for 2nd column it will run 2 times and so on.
<?php
for($i=1;$i<7;$i++){ //for loop for columns
	for($j=1;$j<=$i;$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+.