110. PHP Program to Print Number triangle.
How does this program work?
- This program is used to print Number Triangle using PHP.
Here is the code
<html>
<head>
<title>PHP Program To print Triangle Pattern</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=$n;$i>=1;$i--)
{
for($j=$n;$j>$i;$j--)
{
echo " ";
echo " ";
}
for($j=1;$j<=$i;$j++)
{
echo ($i);
echo " ";
echo " ";
}
echo "</br>";
}
return 0;
}
?>
</body>
</html>