Hi, I’ve watched several videos on PHP multi-dimensional arrays hoping to find one similar to what I have so I can see how to expand it from a 2D to a 3D but none of the examples in the videos were coded like this one. I want to change this one from 2D to 3D. Thank you for taking a look.
[code=php]<?php
$meat = array (‘beef’, ‘mutton’, ‘poultry’, ‘venison’);
$fruits = array (‘apples’, ‘oranges’, ‘peaches’, ‘pears’);
$veggies = array (‘potatoes’, ‘carrots’, ‘turnips’, ‘beets’);
$dairy = array (‘yogurt’, ‘curds’, ‘whey’, ‘ice cream’);
$grain = array (‘barley’, ‘rice’, ‘oats’, ‘maize’);
$food = array ($meat, $fruits, $veggies, $dairy, $grain);
echo “<table border=”1″>n”;
echo ” <tr><th>Meats</th><th>Fruits</th><th>Veggies</th><th>Dairy</th><th>Grains</th></tr>n”;
for ($i = 0; $i <= 3; $i++) { // rows
echo ” <tr>”;
for ($j = 0; $j <= 4; $j++) { // columns
echo “n <td>”;
echo $food[$j][$i]; // cells
echo “</td>”;
}
echo “n </tr>n”;
}
echo “</table>n”;
?>