154. PHP Program to print triangle pattern using name.
How does this program work?
- This program is used to print triangle using with name in PHP.
Here is the code
<html>
<head>
<title>PHP Program To print triangle pattern using with name</title>
</head>
<body>
<form method="post">
<table border="0">
<tr>
<td> <input type="text" name="name" value="" placeholder="Enter string"/> </td>
</tr>
<tr>
<td> <input type="submit" name="submit" value="Submit"/> </td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit'])) {
$n = $_POST['name'];
//Find the length of string
$length = strlen($n);
for ( $i = $length ; $i >0 ; $i-- )
{
for( $j = 0 ; $j < $i ; $j++ )
{
echo( $n[$j]);
echo " ";
}
echo "<br>";
}
return 0;
}
?>
</body>
</html>