041 - multidimensional Associated Array
Array
(
    [Krishna] => Array
        (
            [physics] => 85
            [maths] => 78
            [chemistry] => 89
        )

    [Salman] => Array
        (
            [physics] => 68
            [maths] => 73
            [chemistry] => 79
        )

    [Mohan] => Array
        (
            [physics] => 62
            [maths] => 67
            [chemistry] => 92
        )

)
Krishna85 78 89
Salman68 73 79
Mohan62 67 92
Student Name Physics Math Chemistry
Krishna 85 78 89
Salman 68 73 79
Mohan 62 67 92
<?php // 041 - multidimensional Associated Array echo "</br><span class='myheading'>041 - multidimensional Associated Array</span></br>"; $marks_041 = [ // associated array "Krishna" => [ // associated array "physics" => 85, // key with value "maths" => 78, "chemistry" => 89 ], "Salman" => [ "physics" => 68, "maths" => 73, "chemistry" => 79 ], "Mohan" => [ "physics" => 62, "maths" => 67, "chemistry" => 92 ] ]; echo "<pre>"; print_r($marks_041); // print using = print_r echo "</pre>"; foreach($marks_041 as $key_041 => $v1_041){ // print using = Foreach echo $key_041; foreach($v1_041 as $v2_041){ echo $v2_041 . " "; } echo "</br>"; } // print using = table echo "<table border='2px' cellpadding='5px' cellspacing='0'> <tr> <th>Student Name</th> <th>Physics</th> <th>Math</th> <th>Chemistry</th> </tr>"; foreach($marks_041 as $key_041 => $v1_041){ echo "<tr> <td>$key_041</td>"; foreach($v1_041 as $v2_041){ echo "<td> $v2_041 </td>"; } echo "</tr>"; } echo "</table>"; ?>