Powered by Blogger.

Print Star Pattern in PHP



Print Star Pattern in PHP

Today we will learn about how to Pint Star pattern in php. Here simple pattern is given below.
*
* *
* * *
* * * *
* * * * *
* * * *
* * *
* *
*

Print Triangle of Stars in PHP

<?php
 for($i=0;$i<=4;$i++)
{
for($k=4;$k>=$i;$k–)
{
echo "  ";
}
for($j=1;$j< =$i;$j++)
{
 echo "*  ";
}
echo "  ";
}
for($i=3;$i>=1;$i–)
{
for($k=4;$k>=$i;$k–)
{
echo "  ";
}
for($j=1;$j< =$i;$j++)
{
 echo "*  ";
}
echo "  ";
}
?>

Print Below Pattern

*
***
****
***

Example for print star pattern 

< ?php
$s="*"; for($a=5; $a>=1; $a–)
{
if($a%2 != 0)
{
for($b=5; $b>=$a; $b–)
{
echo $s;
}
echo "<br>";
}
}
for($a=2; $a< =5; $a++)
{
 if($a%2 != 0)
{
 for($b=5; $b>=$a; $b–)
{
echo $s;
}
echo "<br>";
}
}
?>




facebook
google-plus
twitter
pinterest

No comments :

Post a Comment

HTML Tutorial

images

About Sitesbay

This blog is related to Java Tutorial, C++ Tutorial, C Tutorial, Online Earning tips and more in very simple and easy way. Here i will try to give complete idea related to all new technology.

Java Tutorial

Java is Object oriented programming language, It is more secure and high performance language.

C++ Tutorial

C++ is also Object oriented programming language, It is more simple and easy to learn.

 
https://sitesbay.blogspot.com/?utm_medium=d2898efa59afcc0bc411921036e22b767ca37b09