I need help! I am trying to find a way to get all the possible combinations of all attribute-value pairs in an array. For example, I have two arrays $attributes where the index is the attribute id and the value is the attribute name. The other array is $values where the index is the attribute id and the value is an array of all the related value names.
For example: (shortened for example)
PHP Code:
$attributes = array( 10 => 'school_type', 20 => 'grade_level', 30 => 'format', ); $values = array( // For attribute school_type 10 => array( 'Public School', 'Home School', ), // For attribute grade_level 20 => array( '1st Grade', '2nd Grade', '3rd Grade', ), // For attribute format 30 => array( 'Individual', 'Group', ), );
I need a way to create a master array with all possible combinations for each attribute-value pair so the resulting array would look like this:
Code:
Array
(
[0] => Array
(
[10] => Public School
[20] => 1st Grade
[30] => Individual
)
[1] => Array
(
[10] => Public School
[20] => 1st Grade
[30] => Group
)
[2] => Array
(
[10] => Public School
[20] => 2nd Grade
[30] => Individual
)
[3] => Array
(
[10] => Public School
[20] => 2nd Grade
[30] => Group
)
[4] => Array
(
[10] => Public School
[20] => 3rd Grade
[30] => Individual
)
[5] => Array
(
[10] => Public School
[20] => 3rd Grade
[30] => Group
)
[6] => Array
(
[10] => Home School
[20] => 1st Grade
[30] => Individual
)
[7] => Array
(
[10] => Home School
[20] => 1st Grade
[30] => Group
)
[8] => Array
(
[10] => Home School
[20] => 2nd Grade
[30] => Individual
)
[9] => Array
(
[10] => Home School
[20] => 2nd Grade
[30] => Group
)
[10] => Array
(
[10] => Home School
[20] => 3rd Grade
[30] => Individual
)
[11] => Array
(
[10] => Home School
[20] => 3rd Grade
[30] => Group
)
)
__________________
<mgraphic /> - I don't have a solution but I admire the problem.
|