I am doing a LAB exercise about using the foreach and for loop to print a table in PHP. But I have met the problem now.
The question let me to print a table like this.
Here is my code:
<?php
        $subjects = array(
            "sem1" => array("Prog", "DP", "NF", "ENG", "SDD"),
            "sem2" => array("IP", "DMS", "OOP", "SA"),
            "sem3" => array("INSP", "SAP", "ITP"),
        );
        //maximum number of subjects
        $maxSubNum = 10;
        //creating table
        echo "<table border='1'>";
            //loop the array
            foreach ($subjects as $sem => $subjectArray) {
                //print <tr>
                echo "<tr>";
                //print semeester number in <td>, bold the text
                echo "<td><b>$sem</b></td>\n";
                //loop 10 times
                for ($i=0; $i < $maxSubNum; $i++) {
                    //check if subject exists
                    if (isset($subjectArray)) {
                        //print subject in <td>
                        echo "<td>$subjectArray[$i]</td>\n";
                    } else {
                        //print empty in <td>
                        echo "<td></td>\n";
                    }
                }
                //closing <tr>
                echo "</tr>\n";
            }
        echo "</table>\n";
        ?>
Finally, it warns me those notices although I can print out he table.
Anyone can help? Please?
 
     
    