PHP Alphabet Pattern 33

Last Updated:

PHP Alphabet Pattern 33

Try to print the following alphabet pattern using PHP.

Print This Output
    A
   B B
  C   C
 D     D
E       E

Source Code

PHP Compiler
<?php $alpha = range('A', 'Z'); for($i=0; $i<=4; $i++) { for($j=4; $j>=0; $j--) { if($i == $j) echo "<div>".$alpha[$j]."</div>"; else echo "<div>&nbsp;</div>"; } for($k=1; $k<=4; $k++) { if($i == $k) echo "<div>".$alpha[$k]."</div>"; else echo "<div>&nbsp;</div>"; } echo "<br>"; } ?>

Share this Page

Meet the Author