Skip to main content

Posts

Showing posts from July, 2017

How to create STAR PATTERN in PHP

STAR Pattern Printing using PHP for loop Pattern: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Code: for($i=0; $i<5; $i++) { for($j=0; $j<5; $j++) { print_r(" * "); } print_r("<br/>"); } Pattern: * * * * * * * * * * * * * * * Code: for($i=0; $i<5; $i++) { for($j=0; $j<=$i; $j++) { print_r(" * "); } print_r("<br/>"); } Pattern:              *          * *        * * *     * * * *  * * * * * Code: for($i=0; $i<5; $i++) { for($j=5; $j>=$i; $j--) { print_r("&nbsp; ");  } for($k=0; $k<=$i; $k++) { print_r("*"); } print_r("<br/>"); } Pattern: * * * * *    * * * *       * * *          * *             * Code: $temp = 1; for($i=5; $i>=1; $i--) { for($k=$temp; $k>=0; $k--) { print_r(" &nbsp;"); } for($j=$i; $j>=1; $j--) { print_r("