karthickr Posted April 3, 2011 Share Posted April 3, 2011 Hi, I am new to PHP. Can someone explain me clearly how to use while loop inside while loop to print "*" in square shape. Thank you for your help. Link to comment https://forums.phpfreaks.com/topic/232550-how-to-use-while-loop-inside-while-loop/ Share on other sites More sharing options...
spiderwell Posted April 3, 2011 Share Posted April 3, 2011 im just gonna try write this now on the fly, lol $verticalstars = 10; $horizontalstars = 10; $countvert; $counthori; for($countvert = 0;$countvert < $verticalstars;$countvert++) { for($counthori = 0;$counthori < $horizontalstars;$counthori++) { echo "*"; } echo "<br>"; } so the first loop is how many 'rows' , and inside each loop of a row is the number of 'cols' per row, the second loop executes completely, then is recalled when the first loop loops again. hope that makes some sense Link to comment https://forums.phpfreaks.com/topic/232550-how-to-use-while-loop-inside-while-loop/#findComment-1196193 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.