105. 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=1;$i<=$n;$i++)
{
for($j=$i;$j<$n;$j++)
{
echo " ";
echo" ";
}
/* Print numbers in increasing order or row */
for($k=$i; $k>=1; $k-- )
{
echo $i;
}
echo "</br>";
}
return 0;
}
?>
</body>
</html>

