Nested loop execution
📖 Scenario: You are organizing a small event and want to print a seating chart. There are 3 rows and each row has 4 seats. You want to list each seat by its row and seat number.
🎯 Goal: Create a PHP program that uses nested loops to print each seat as "Row X Seat Y" for all rows and seats.
📋 What You'll Learn
Create a variable
$rows with the value 3Create a variable
$seats_per_row with the value 4Use a nested
for loop where the outer loop uses $row from 1 to $rowsThe inner loop uses
$seat from 1 to $seats_per_rowPrint each seat as
Row X Seat Y where X is the row number and Y is the seat number💡 Why This Matters
🌍 Real World
Nested loops are useful when you need to work with tables, grids, or any data with rows and columns, like seating charts or calendars.
💼 Career
Understanding nested loops is important for programming tasks involving multi-dimensional data, such as processing images, spreadsheets, or game boards.
Progress0 / 4 steps