star pattern in php

Today, We want to share with you star pattern in php.In this post we will show you pyramid program in php using while loop, hear for reverse pyramid program in php we will give you demo and example for implement.In this post, we will learn about Print Star Pattern In PHP with an example.

Print star pattern in PHP

";   	
}  
?>

results

Output
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

Pattern 2

";   	
}  
?>

results

Output
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5

Pattern 3


";   	
}  
?>

results

Output
*
* *
* * *
* * * *
* * * * *

Pattern 4

$ct; $k--)	 
{	  
//print one space throgh html ;
echo " ";	  
}	
for($pd=1;$pd<=$ct;$pd++)	  
{	  	
echo "*";	  
}	  	
echo "
"; } ?>

results

Output
     *
    * *
   * * *
  * * * *
 * * * * *

Pattern 5


=1;$pd--)
{  
echo "* ";  
}  
echo "
"; } ?>

results

Output
* * * * *
* * * *
* * *
* *
*

Pattern 6


=$ct;$k--)
{  
echo "  ";  
}  
for($pd=1;$pd<=$ct;$pd++)
{  
echo "*  ";  
}  
echo "
"; } for($ct=4;$ct>=1;$ct--) { for($k=5;$k>=$ct;$k--) { echo " "; } for($pd=1;$pd<=$ct;$pd++) { echo "* "; } echo "
"; } ?>

Pattern 7


';   
}  
for($ct=5; $ct>=1; $ct--)
{   
for($pd=1; $pd<=$ct; $pd++)
{  
echo ' * ';   
}   
echo '
'; } ?>

Pattern 8


=1; $ct--)  
{  
if($ct%2 != 0)  
{  
for($pd=5; $pd>=$ct; $pd--)  
{  
echo "* ";  
}  
echo "
"; } } for($ct=2; $ct<=5; $ct++) { if($ct%2 != 0) { for($pd=5; $pd>=$ct; $pd--) { echo "* "; } echo "
"; } } ?>

Pattern 9

";

}
?>

results

Output :
1 2 3
2 4 6
3 6 9

Number Pattern

 

results

Output
1 
2 2 
3 3 3 
4 4 4 4 
5 5 5 5 5 

Star Triangle Pattern 2

=1;$ct--){ 
	for($pd = 1; $pd < $ct; ++$pd) { 
		$start_triangle.=$string." "; 
	} 
	$start_triangle.="\r\n"; 
} 

return $start_triangle; 
} 
echo triangle_pattern(9); 
?> 

results

Output
* 
* * 
* * * 
* * * * 
* * * * * 
* * * * 
* * * 
* * 
* 

PHP programs for printing pyramid patterns

 

results

Output
* 
* * 
* * * 
* * * * 
* * * * * 

I hope you get an idea about star pattern 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