Home >Backend Development >PHP Tutorial >How to output an isosceles triangle in PHP_PHP tutorial
This article explains how to output an isosceles triangle in PHP. Share it with everyone for your reference. The specific implementation method is as follows:
ใ?
2 3 4 5 6 7 8 9 17 18
<๐>19<๐>
<๐>20<๐>
<๐>21<๐>
<๐>22<๐>
<๐>23<๐>
<๐>24<๐>
<๐>25<๐>
|
<๐>
<๐>function isosceles($line,$sing){<๐>
<๐>$tab ='=';<๐>
<๐>for($i=1;$i < $line 1;$i ){<๐>
<๐>$blank = print_blank($i,$line,$tab);<๐>
<๐>$code = print_code($i,$sing);<๐>
<๐>echo $blank.$code.$blank." "; } } function print_blank($num,$line,$tab){ $blank =''; for($i=$num;$i<$line;$i ){ $blank.=$tab; } return $blank; } function print_code($num,$sing){ $code =''; for($i=0;$i<(2*($num-1) 1);$i ){ $code.=$sing; } return $code; } $line = 5; $sing = "*"; isosceles($line,$sing); |