PHP Tutorial

PHP Home

PHP Functions

PHP String Functions

PHP Interview Programs

PHP Common ProgramsPHP Array ProgramsPHP Converter ProgramsPHP Star Patterns ProgramPHP Number Patterns ProgramPHP Alphabet Patterns Program

PHP Reference

ASCII Table

PHP Number Pattern 56

Last Updated:

PHP Number Pattern 56

Try to print the following number pattern using PHP.

Print This Output
        1
      1 2 1 
    1 2 3 2 1
  1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1

Source Code

PHP Compiler
<?php for($i=1; $i<=5; $i++) { for($j=5; $j>$i; $j--) echo "<div></div>"; for($k=1; $k<=$i; $k++) echo "<div>".$k. "</div>"; $n = $k - 1; for($m=1; $m<$i; $m++) echo "<div>".--$n. "</div>"; echo "<br>"; } ?>

Share this Page

Meet the Author