How to print the rhombus pattern in the php language of the stars using the for loop
ADVERTISEMENTS
How to print the rhombus pattern in the php language of the stars using the for loop. There are you will learn how to print the rhombus pattern in the php language of the stars using the for loop.
Take an example to print this pattern of stars through a php program:
<?php
// How to print the rhombus pattern in the
// PHP language of the stars using the for loop
// It's the size of the pattern
$x = 10;
if ($x > 0) {
// calling function to print the pattern
rhombusPattern($x);
}
// It's the driver function to print the rhombus pattern
function rhombusPattern($x = 0) {
if (! $x)
return FALSE;
for ($i = 1; $i <= $x; $i++) {
// print the spaces
for ($j = $i; $j < $x; $j++)
echo " ";
// print the stars
for ($j = 1; $j <= $x; $j++)
echo "*";
echo "\n";
}
}
?>
Output
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********