For the fresher it’s easy way to improve the logic and programming syntax. In php we can make the different types numerical triangle. Using for loop or foreach loop we can make a logic to show the triangle, Check below the programming syntax in front of out put:.

1 1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1
1 1 1 1
1 1 1
1 1
1
<?php
for($i=0;$i<=7;$i++){
for($j=7-$i;$j>=1;$j--){
echo "1";
}
echo "<br>";
}
?>
7 6 5 4 3 2 1
6 5 4 3 2 1
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1
<?php
for($i=0;$i<=7;$i++){
for($j=7-$i;$j>=1;$j--){
echo $j;
}
echo "<br>";
}
?>
7 7 7 7 7 7 7
6 6 6 6 6 6
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
<?php
for($i=7;$i>=1;$i--){
for($j=$i;$j>=1;$j--){
echo $i."&nbsp;";
}
echo "<br>";
}
?>

Related posts:

Categories: PHP

3 Responses so far.


  1. Jass says:

    Great, thanks for sharing your knowledge. Really its very interesting and helpful.

  2. riko says:

    Help mr please

    54321
    5432
    543
    54
    5

Leave a Reply


*