Complete Code For Printing Alphabet Triangle Pattern Using PHP.
<!DOCTYPE html> <html> <head> <title>How Do I Print Alphabet Triangle Pattern Using PHP</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet"> </head> <style> body { background: black; } </style> <body> <body> <div class="container"> <br/><br/> <div class="text-center"> <h1 id="color" style="color: white;">Print Alphabet Triangle Pattern Using PHP</h1> </div> <div class="well"> <?php echo "<h3>First pattern</h3>"; $alpha = range('A', 'Z'); for($i=0; $i<5; $i++){ for($j=5; $j>$i; $j--){ echo $alpha[$i]; } echo "<br>"; } echo "<h3>Second pattern</h3>"; $alpha = range('A', 'Z'); for($i=0; $i<5; $i++){ for($j=0; $j<=$i; $j++){ echo $alpha[$i]; } echo "<br>"; } echo "<h3>Third pattern</h3>"; $alpha = range('A', 'Z'); for($i=0; $i<5; $i++){ for($j=0; $j<=$i; $j++){ echo $alpha[$j]; } echo "<br>"; } echo "<h3>Fourth Pattern</h3>"; $alpha = range('A', 'Z'); for($i=0; $i<5; $i++){ for($j=4; $j>=$i; $j--){ echo $alpha[$j]; } echo "<br>"; } echo "<h3>Fifth Pattern</h3>"; $alpha = range('A', 'Z'); for ($i=5; $i>=1; $i--) { for ($j = 0; $j <= $i; $j++) { echo ' '; } $j--; for ($k = 0; $k <= (5 - $j); $k++) { echo $alpha[$k]; } echo "<br>\n"; } echo"<h3>Sixth Pattern</h3>"; $num = 65; for ($i = 0; $i < 5; $i++) { for ($j = 0; $j <= $i; $j++ ) { $ch = chr($num); echo $ch." "; } $num = $num + 1; echo "<br>"; } echo"<h3>Seven Pattern</h3>"; for ($i = 0; $i < 5; $i++) { for ($j = 0; $j <= $i; $j++ ) { $ch = chr($num); echo $ch." "; $num = $num + 1; } echo "<br>"; } ?> </div> </div> </body> </html>