Great!! I liked your answer and I thanked you too for the great help.
But ,yes .I am looking for variable input , that is ,I want user to input the number of rows and then the output in the form of a triangle of stars with the specified no. of rows will be displayed.
Also,I will request you to give me in the same format as the code I posted.I mean can you pls tell me how to display with loops only without using PHP array?
Or if you can give me in "C" Language that will also be fine.
Whichever I would request you not to the format I have posted ,i.e. ,pls use the loops (whatever u can use -while,for,if-else without using any advanced features of php or any other language except C programming as I said before)!!
Problem is you perhaps didn't see the picture I attached!!
It is a hollow triangle and in your case it is a filled one!!
Please see the attached bmp image .
Also,if it is possible you can also write in C language.
But still I have a few questions @dan-dan.
Firstly,how u fix how many pixels are needed to give the spaces?
2ndly,what is the spacer doing when there is padding?
3rdly,why r u giving padding to the asterisks?
4thly,can u tone down ur porgram to a more simpler one like the one I wrote?
1) The below loop works out how many points are needed for a full triangle, then echos an astrisk for the first and last points, and empty spans for the points in between. Bare in mind I originally thought it was a filled triangle. The class 'spacer' specifies the width of the spacer from the CSS. I just changed the number till it looked right.
2) The padding was to create space in between the astrisks. Like said above the spacer was to replace what were the filling astrisks.
3) So they're not squashed together.
4) This isn't complex in the slightest! It isn't using any advanced features either. In fact it uses the same loops as yours. You can get rid of the CSS and just use HTML, but why take a step back?
Also, you're not just using PHP, you're also using HTML within your PHP. HTML and CSS work hand-in-hand, so it might be worth learning.
I'm not going to write the program again, I'm sure you can manage the tweaking.
I do know CSS nd HTML,but actually for some reason I want it in PHP(& of course HTML but no CSS) only.A program as u very well know can be written in HTML and PHP only without using any CSS at all.then why dont u write a program without CSS for my sake? Actually I originally want to write a C program so I need the loop logic clearly ,of course CSS is now a regular practice but as I aid for the above reason I want only in HTML and PHP only.
Hope u now got me!!
Now sorry ,I cannot manage the tweaking ,can you do me that one last favour pleaseee?