I am working on a project where a company sells a multitude of valves with a vast array of variations and need to build a site map with links to every valve data as the current navigation does not use conventional links but codes built via a user interacting with the many options on the page. I have been able to generate everything up until the options which begin to get very tricky because of the vast array of combinations of these options there are and the rules that they follow.
I am attempting to build every option string combinations with the rules you can find below.
Given the array of option codes (at the end of the post) I must generate a list of all possible combinations but they must follow the order that they are presented and follow the rules given by the row_mod. For example when the option_code of O is in the combinations the option_code of ON and OP are not allowed to be in the combination.
The only row_mod info that needs to be followed currently when building these strings is the "naWithOp##" as that refers to another option that is not allowed to be with it.
Some of the possible combinations that would need to come out of the script would be:
- OTKZ
- OTK
- OT
- OTOSZ
- OTOS
- O
- OL
- OLKZ
- OLK
I know this isn't even close to the exhaustive list of how many are actually possible but I can't figure out how to generate all the possible combinations.
Array
(
[0] => Array
(
[option_code] => O
[row_mod] => allowAll naWithOpON naWithOpOP
)
[1] => Array
(
[option_code] => ON
[row_mod] => allowAll naWithOpO naWithOpOP
)
[2] => Array
(
[option_code] => OP
[row_mod] => allowAll naWithOpO naWithOpON
)
[3] => Array
(
[option_code] => T
[row_mod] => allowAll naWithOpL
)
[4] => Array
(
[option_code] => L
[row_mod] => allowAll naWithOpT naWithCoilX
)
[5] => Array
(
[option_code] => K
[row_mod] => allow2 allow3 allow3P naWithOpOS
)
[6] => Array
(
[option_code] => OS
[row_mod] => allow2 allow3 allow3P naWithOpK
)
[7] => Array
(
[option_code] => Z
[row_mod] => allowAll naWithPreB
)
)
Basically I must start on the first option code and iterate down the list starting with the first given option 'O' then go to the next option 'ON' and check whether its valid and if it is then add it to the current combination. And so on and so forth building allowed combinations and storing them to an array.
User Interface example: I created a jsfiddle that is interactive in the way that the options work together. Found here
I'm not sure what approach I should be taking but I have tried using recursive algorithms to no avail.