Making of square pattern using php
The given squire pattern is made from loop .There are four type of loop in php
1. for loop
2.while loop
3. do while loop
4. foreach loop
I will tell you about loop in next post .use this code make square pattern.
Html code
<html>
<head></head>
<body>
<br><br><br><br>
<?php
$a=6;
for ( $b = 1 ; $b <= 6 ; $b++ )
{
echo"                ";
for ( $c = 1 ; $c <= $a ; $c++ )
{
echo"  ";//using for blank space
}
$a--;
for ( $c = 1 ; $c <= 2*$b - 1 ; $c++ )
{
echo"*";
}
echo"<br>";
}
$w=1;
for ( $d=6;$d>=1;$d-- )
{
echo"                ";
for ( $e=1;$e<=$w;$e++ )
{
echo"  ";
}
$w++;
for ( $e=1;$e<=2*$d-1;$e++ )
{
echo"*";
}
echo"<br>";
}
echo"uk";
?>
</body>
</html>
Note:
No comments:
Post a Comment