PHP Program to Draw a Triangle 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. Hear we are using three for loops first loop is for number of columns second loop is for number of spaces in rows and the last loop is to print number of stars in the loop.
<?php
for ($i=5;$i>0;$i--) { //loop for columns
	for ($k=5;$k>$i;$k--) { // loop for spaces in rows
		echo "&nbsp &nbsp";
	}
	for ($j=0;$j<$i;$j++) { // loop for star in rows
		echo "* ";
	}
	echo "<br>";
}
?>

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+.