How to print a triangular pattern in php
March 18, 2016
We can print this pattern in php. For this we need Variables and ‘for’ loops. First we have Variables in which Symbols are passing as a string to print pattern. First ‘for’ loop is used for number of row and second & third ‘for’ loop is used for numbers in a row. ‘if’ condition is used to print empty space and ‘elseif’ condition used to print symbol.
<?php $p="|"; $q="\\"; $r=" _ "; for($a=1; $a<=6; $a++){ for($b=$a; $b<=$a; $b++){ echo $p; for($c=1; $c<=$a-1; $c++){ if($a <= 5){ echo "   "; } elseif($a == 6 && $c<=$a/2){ echo $r; } } echo $q; } echo "<br>"; } ?> |
6 Comments
how to print this series in php???
*
* *
* * *
Did you check this? http://www.powerfaq.com/how-to-make-the-star-triangle-in-php/
how to print this series in php???
*
* *
* * *
Please check here http://www.powerfaq.com/how-to-make-the-star-triangle-in-php/
how to print this pattern in php.?
*
* *
* * *
Please check here http://www.powerfaq.com/how-to-make-the-star-triangle-in-php/