Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this PHP exercise, use two for loops, one nested inside another. Create the f

ID: 3729363 • Letter: I

Question

In this PHP exercise, use two for loops, one nested inside another. Create the following multiplication table:

1

2

3

4

5

6

7

2

4

6

8

10

12

14

3

6

9

12

15

18

21

4

8

12

16

20

24

28

5

10

15

20

25

30

35

6

12

18

24

30

36

42

7

14

21

28

35

42

49



Unless you want to try your hand at CSS styling, don't be concerned about the appearance of the table, its borders and text alignment. The point of the exercise it to create the data and the table tags using the for loops.

1

2

3

4

5

6

7

2

4

6

8

10

12

14

3

6

9

12

15

18

21

4

8

12

16

20

24

28

5

10

15

20

25

30

35

6

12

18

24

30

36

42

7

14

21

28

35

42

49

Explanation / Answer

<html>
<body>
  
<?php
for( $i = 1; $i<=7; $i++ ) {
for ( $j = 1; $j<=7; $j++ ) {
$val = $i * $j;
echo("$val ");
}
echo("<br>");
}
?>
  
</body>
</html>

Output:

1 2 3 4 5 6 7
2 4 6 8 10 12 14
3 6 9 12 15 18 21
4 8 12 16 20 24 28
5 10 15 20 25 30 35
6 12 18 24 30 36 42
7 14 21 28 35 42 49