Alphabet Triangle pattern
Character patterns
Alphabet Triangle pattern
1] range() with for loop (Patterns)
Example :-
<?php
$alpha=range('A','c');
for($i=0;$i<5;$i++)
{
for($j=5;$j>$i;$j--)
{
echo $alpha[$i];
}
echo "<br>";
}
?>
1] range() with for loop (Patterns)
Output
Example
<?php
$alpha=range('A','Z');
for($i=0;$i<5;$i++)
{
for($j=0;$j<=$i;$j++)
{
echo $alpha[$i];
}
echo"<br>";
}
Output
(Patterns)
Example
<?php
$alpha =range('A','z');
{
for($i=0;$i<5;$i++)
{
for($j=0;$j<=$i;$j++)
{
echo $alpha[$j];
}
echo "<br>";
}
}
3] range() with for loop
Output
4] range() with for loop
(Patterns)
Example
<?php
$alpha =range('A','Z');
for($i=5; $i>=1; $i--)
{
for($j=0; $j<=$i;$j++)
{
echo '';
}
$j--;
for($k=0;$k<=(5-$j);$k++)
{
echo $alpha[$k];
}
echo "<br>\n";
}
?>
4] range() with for loop
Post a Comment