153. PHP Program to print pyramid pattern using name.
How does this program work?
- This program is used to print pyramid using with name in PHP.
Here is the code
<html>
<head>
<title>PHP Program To print pyramid 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 = 0 ; $i < $length ; $i++ )
{
for($j = $length; $j>$i; $j--)
{
echo(" ");
echo " ";
}
for( $j = 0 ; $j <= $i ; $j++ )
{
echo( $n[$j]);
echo " ";
}
echo "</br>"; }
return 0;
}
?>
</body>
</html>

