I have an N amount of products with an n amount of properties.
How exactly could I use a for each inside a for each to get the properties of each product? Is it by storing an array in an array or something?
Thanks
I have an N amount of products with an n amount of properties.
How exactly could I use a for each inside a for each to get the properties of each product? Is it by storing an array in an array or something?
Thanks
$products = array(
array('name' => 'Product 1', 'color' => 'red', 'size' => 'large'),
array('name' => 'Product 2', 'color' => 'blue', 'size' => 'medium'),
array('name' => 'Product 3', 'color' => 'green', 'size' => 'small')
);
foreach ($products as $product) {
foreach ($product as $property => $value) {
echo $property . " = " . $value . ",";
}
echo "<br />";
}