184. PHP Program to Print Rhombus using numbers.
How does this program work?
- This program is used to print rhombus using numbers in PHP.
Here is the code
<html>
<head>
<title> PHP Program To print rhombus using numbers</title>
</head>
<body>
<form method="post">
<table border="0">
<tr>
<td> <input type="text" name="num" value="" placeholder="Enter no.of rows"/> </td>
</tr>
<tr>
<td> <input type="submit" name="submit" value="Submit"/> </td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit'])) {
$n = $_POST[ 'num'];
for($i=0;$i<=$n-1;$i++)
{
for ($d=$n-$i; $d > 0; $d--)
{
echo " ";
}
for($j=1;$j<=$i;$j++)
{
echo " ".$i." ";
}
echo "<br>";
}
for($i=$n-2;$i>=1;$i--)
{
for ($d=0; $d <= $n-1-$i; $d++)
{
echo " ";
}
for($j=$i;$j>=1;$j--)
{
echo " ".$i." ";
}
echo "<br>";
}
return 0;
}
?>
</body>
</html>