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); |