Number pattern programs in php Examples

Today, We want to share with you number pattern programs in php.In this post we will show you number pyramid program in php, hear for star pattern in php we will give you demo and example for implement.In this post, we will learn about PHP Nested Forloop – Exercises Pyramid Program Solution with an example.

number pyramid program in php

Number pattern triangle in PHP can be printed using for and foreach loop. There are a some of patterns in number pattern. Some of them are display here.

Number Triangle

Example 1:

";  
}  
?>  

Example 2: PHP program to print the number pattern
To print the number pattern in PHP


Example 3: Program to print Triangle number in reverse pattern

=1;$no--)
 {
   for($x=$no;$x>=1;$x--)
    {
     echo $x." ";
     if($x==1)
     {
       echo " ";
       echo "
"; } } } ?>

Results:

6 5 4 3 2 1 
5 4 3 2 1 
4 3 2 1 
3 2 1 
2 1 
1

Program to print Triangle number in reverse pattern

=1;$x--)
 { echo $x." ";
   if($x==1)
     {
       echo " ";
       echo "
"; } } } ?>

Results:

1 
2 1 
3 2 1 
4 3 2 1 
5 4 3 2 1 
6 5 4 3 2 1

I hope you get an idea about PHP Number Triangle Program(number pattern programs in php).
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment