I have two arrays of attributes that describe products in the database:
$sizes = array(
'Shirt Size' => array('Small', 'Medium', 'Large'),
'Sleeve Size' => array('Short', 'Long')
); // Level 1
$colors = array(
'Shirt Color' => array('Black', 'Red'),
'Sleeve Color' => array('White', 'Orange')
); // Level 2
The contents of those arrays above change frequently, and at some points "colors" or "sizes" may be empty.
What is the most efficient way to go about grouping these attributes, so I can see (for example) all Small & Short, Black & Orange products? I'm not as concerned with calculating the quantity of each attribute combination as I am with creating the attribute grouping mechanism.
I'd like to end up with a table like this:
SHIRT SIZE SLEEVE SIZE SHIRT COLOR SLEEVE COLOR QTY
Small Short Black White 6
Small Short Black Orange 1
Small Short Red White 4
Small Short Red Orange 2
Small Long Black White 3
Small Long Black Orange 2
...
Large Long Red Orange 5