nested loops heeeelp

You are to create a program using nested looping. Your program is to have a menu asking the user to select which pattern to create and how many rows to use (it should accept 1 to 10 rows and keep the aspect ratio of the pattern). The patterns are 1 - Box, 2 - V, 3 - Inverted V. Note, if I select pattern 1 with 10 rows, the box will have 10 asterisks in the first row.



Okay so i came up with the box but i have been getting stuck at getting the V or inverted V. Can anyone help me
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$w = 5;
$ww = 5;
for($x=0; $x<$w; $x++){
for($y=$x; $y>0; $y--){
echo "&nbsp";
}
echo "*";
for($z=$ww; $z>0; $z--){
echo "&nbsp&nbsp";
}
echo "*";
echo "<br>";
$ww--;
}

while($w!=0){
echo "&nbsp";
$w--;
}
echo "**";


hope you know php ^^

br = endl
echo = cout
&nbsp = space
Last edited on
Topic archived. No new replies allowed.