I have a PHP array that looks like this:
Array
(
[340] => Array
(
[1] => 1
[2] => 18
[3] => 23
)
[341] => Array
(
[1] => 1
[2] => 17
[3] => 23
)
[342] => Array
(
[1] => 1
[2] => 16
[3] => 23
)
[343] => Array
)
The array is actually longer and contains about 40 elements. There will be other arrays that contain a different number of child elements. The array is formatted as
productID => array (
$attributeID => attributeValueID,
$attributeID => attributeValueID,
$attributeID => attributeValueID
)
What I need is an array that shows the valid values for all other attributes. The output array might looks something like
Array
(
18 => array(
1 => array(
11, 12, 13, 14, 15
)
2 => array(
19, 20, 21, 22
)
)
19 => array(
1 => array(
11, 13, 14, 15
)
2 => array(
21, 22
)
)
The format of this array is
attributeValueID => array(
attributeID => attributeValues,
attributeID => attributeValues
)
I've been working with some recursion functions but I've only been able to get a list of every possible combination between all the values which isn't what I need. Any help would be greatly appreciated.
Clarification on what I mean by "valid" values: What the 1, 2, and 3 values represent here are color, size, and length. The ultimate goal here is to create a series of javascript arrays I'll use to update options on the page when a user selects values. For example when they select the color black I need to update the sizes and lengths on the page to reflect only sizes and lengths available in black. I can create the arrays manually but this is not a good solution.