0

I would know how to find all combinations per each element in a multidimensional array looking like this one :

[
    ['1a', '1b',], 
    ['2a','2b','2c',], 
    ['3a',], 
    ['4a','4b',], 
    ['5a','5b','5c','5d',]
]

The output must be a table. I found some Algo but only to get all combinations of a single dimensional array.

It Doesn't have to get all the the combinations in all possible directions. For example the first element of the result should be:

0 => ['1a','2a','3a','4a','5a'],
1 => ['1a','2b','3a','4a','5a'],

I don't have to get doubloons like:

0 => ['1a','2a','3a','4a','5a'],
1 => ['1a','2b','3a','4a','5a'],
2 => ['2a','1a','3a','4a','5a']

With key 0 and key 2 similar..

I Don't know if this is clear enough.

Jonathan Drapeau
  • 2,610
  • 2
  • 26
  • 32
KeizerBridge
  • 2,707
  • 7
  • 24
  • 37

1 Answers1

1

You can try the php pear library math combinatoric:http://pear.php.net/package/Math_Combinatorics.

Micromega
  • 12,486
  • 7
  • 35
  • 72