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 " ";
}
for($k=0;$k<$i*2-1;$k++)
{
if($k===0||$k===2*$i-2)
{
echo "*";
}
else{
echo " ";
}
}
echo "<br>";
}
for($i=1;$i<=$size-1;$i++){
for($j=0;$j<$i;$j++){
echo " ";
}
for($k=($size-$i)*2-1;$k>=1;$k--) {
if($k===1||$k===($size-$i)*2-1){
echo "*";
}
else {
echo " ";
}
}
echo"<br>";
}
?>
php program to print Hollow diamond star pattern
Output:-
Related Post :-
Post a Comment