Php uses the for statement to output triangles. Php uses the for statement to output triangles. This document describes how php outputs triangles using the for statement. Share it with you for your reference. The specific implementation method is as follows :? 1234 php uses the for statement to output triangles
This example describes how php outputs triangles using the for statement. Share it with you for your reference. The specific implementation method is as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
// Phpinfo (); Function Dis ($ num) { If ($ num <= 0) Return; $ TmpRow = 0; For ($ I = 1; $ I <= $ num; $ I ++) { $ TmpRow = $ I <= $ num/2? $ I: $ num-$ I + 1; Echo str_repeat ('*', 2 * $ tmpRow-1 ).' '; } } Dis (19 ); ?> |
I hope this article will help you with php programming.
Examples in this article describes how php outputs triangles using the for statement. Share it with you for your reference. The specific implementation method is as follows :? 1 2 3 4...