輸出具有索引和值的多維陣列並列印到表中

Array 
( 
    [0] => Array 
        ( 
            [id] => 13 
            [category_id] => 7 
            [name] => Leaving Of Liverpool 
            [description] => Leaving Of Liverpool 
            [price] => 1.00 
            [virtual] => 1 
            [active] => 1 
            [sort_order] => 13 
            [created] => 2007-06-24 14:08:03 
            [modified] => 2007-06-24 14:08:03 
            [image] => NONE 
        ) 

    [1] => Array 
        ( 
            [id] => 16 
            [category_id] => 7 
            [name] => Yellow Submarine 
            [description] => Yellow Submarine 
            [price] => 1.00 
            [virtual] => 1 
            [active] => 1 
            [sort_order] => 16 
            [created] => 2007-06-24 14:10:02 
            [modified] => 2007-06-24 14:10:02 
            [image] => NONE 
        ) 

)  

在表中輸出索引和值的多維陣列

<table>
<?php 
foreach ($products as $key => $value) {
    foreach ($value as $k => $v) {
        echo "<tr>";
        echo "<td>$k</td>"; // Get index.
        echo "<td>$v</td>"; // Get value.
        echo "</tr>";
    }
}
?>
</table>