I have an array having three element $base =(#m, #f,#p)
I have a second array having any number of element like $var = (s1, s2)
Now i need to create all possible combinations depending only on the base array. The formula I found is x pow y.
In this example my base array has three element and $var has 2, so pow(3, 2) is 9. I need these nine combinations. i.e
#m#m #m#f #m#p
#f#m #f#f #f#p
#p#m #p#f #p#p
The number of elements in the 2nd array is in effect the length of the generated combinations. As in this example the length of the 2nd array is 2 so all generated strings have length 2.
You can use a recursive function like this:
Working codepad demo