PHP Alphabet Pattern 32

Last Updated:

PHP Alphabet Pattern 32

Try to print the following alphabet pattern using PHP.

Print This Output
    A
   ABA
  ABCBA
 ABCDCBA
ABCDEDCBA

Source Code

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

Share this Page

Meet the Author