You could have seen a lot of programs in C language to print patterns. But a very few blogs / websites teaching how to print patterns in PHP. One of the blog is ours of-course.
In this blog, i am going to teach you how to print a right angled triangle in PHP.
Like this,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<?php if($_GET){ $n = $i = $_GET['stars']; while ($i--){ echo str_repeat('*', $n - $i)."<br>"; } } ?> <html> <head></head> <body> <form> Enter number of lines: <input type="text" name="stars" /> </form> </body> </html> |
You can see the demo here,