0
To create a table in PHP you need to use a multidimensional array. The following example creates an array of cars along with their quantities either sold or in stock. Then you retrieve these data by a foreach loop..
// Create 2D array
$cars = [
// Each car has its own row, just like a table
["Volvo", 22, 18],
["BMW", 15, 13],
["Saab", 5, 2]
];
// Output data
foreach ($cars as $car){
// First Column (Name)
echo $car[0];
echo "\t\t"; // Tab characters for indentation
// Second Column (Quantity in stock)
echo $car[1];
echo "\t\t";
// Third Column (Quantity sold)
echo $car[2];
}