php program to print Hollow diamond star pattern


php program to print Hollow diamond star pattern

php program to print Hollow diamond star pattern

Example :-

<?php
$size =5;
for($i=1;$i<=$size;$i++)
{
    for($j=$size;$j>$i;$j--)
   
        {
            echo "&nbsp;&nbsp;";
        }
        for($k=0;$k<$i*2-1;$k++)
        {
            if($k===0||$k===2*$i-2)
            {
                echo "*";
            }
            else{
                echo "&nbsp;&nbsp;";
                        }
        }
        echo "<br>";
    }
    for($i=1;$i<=$size-1;$i++){
        for($j=0;$j<$i;$j++){
            echo "&nbsp;&nbsp;";
                }
                for($k=($size-$i)*2-1;$k>=1;$k--)  {
                    if($k===1||$k===($size-$i)*2-1){
                 echo "*";
                }
                        else {
                            echo "&nbsp;&nbsp;";
                        }
                    }
                    echo"<br>";
                }
                ?>

php program to print Hollow diamond star pattern

Output:-


php program to print Hollow diamond star pattern



Related Post :-

html id attribute

css menu design

php data and time function

Comments

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

HTML Input Type Submit Syntax and Example