I want to generate all possible combination of array elements to fill a placeholder, the placeholder size could vary.
Let say I have array $a = array(3, 2, 9, 7)
and placeholder size is 6
. I want to generate something like the following:
3,3,3,3,3,3
2,3,3,3,3,3
2,2,3,3,3,3
...........
...........
7,7,7,7,7,9
7,7,7,7,7,7
However (2,3,3,3,3,3)
would be considered the same as (3,2,3,3,3,3)
so the later one doesn't count.
Could anyone point me to the right direction? I know there is Math_Combinatorics
pear
package, but that one is only applicable to placeholder size <= count($a)
.
Edit I am thinking that this one is similar to bits string combination though with different number base