Contents
hide
Print Star Triangles in PHP
<?php
$nr=10; //Number of rows
for($i=1; $i<=$nr ; $i++) // Outer loop
{
for($j=1; $j<=$i; $j++) // Inner loop
{
echo “*”;
}
echo “n”; // Statement for new line
}
?>
//Program execution
// First iteration $i=1 and $j=1 i.e in first row * will print 1 time
// Second iteration for $i=2, $j=1, $j=2 second row will print 2 times
// Third iteration for $i=3, $j=1, $j=2 $j=3 third row will print 3 times
——————————————————–
For program execution and output see the video