I have a rather complex set of data which is available in an array, specifically different options for a single product.
In this example, the product is a cable and is available in different lengths and different colours, so you can get a 1m yellow cable but also a 1m green cable and so on. I want to be able to list these options in accordions but group them by length, so if the customer wanted a 2m cable in yellow, they would click the "2m" accordion and select Yellow from inside the accordion.
Here is an example of one record in the array:
[3775] => Array
(
[id] => 3775
[product_id] => 4928
[active] => 0
[var] => 37:63
[price] => 0.0000
[opts] => Array
(
[37] => 0.3m
[38] => 0.5m
[39] => 1.0m
[40] => 1.5m
[41] => 2.0m
[42] => 3.0m
[43] => 4.0m
[44] => 5.0m
[45] => 6.0m
[46] => 7.0m
[47] => 8.0m
[48] => 10.0m
[49] => 15.0m
[50] => 20.0m
[51] => 25.0m
[52] => 30.0m
[53] => 50.0m
[59] => Grey
[63] => Red
[58] => Green
[55] => Blue
[65] => Yellow
[54] => Black
[62] => Purple
[64] => White
[60] => Orange
[61] => Pink
[56] => Brown
)
)
The [var] key represents the two IDs of the [opts] array, so 37:63 pertains to 0.3m Red.
The rest of the array looks exactly the same (in the sense that the opts array remains the same) but the var, combi and ID will change.
Is there an easy way to group these options by length and then list each available colour underneath?
Thanks in advance.