-1

I have a set of variables (strings), loaded from a database, or from an array:

"AA","BB","CC","DD","EE","FF","GG", ... and so on (about 100 of them)

I would need to be able to 1) calculate all possible variations 2) without repeating strings and 3) limit them to 5 strings per variation:

So for example (result):

Set 1: AA BB CC DD EE
Set 2: AA CC BB EE DD
Set 3: CC BB EE FF GG
Set 4: GG AA BB CC EE
Set 5: CC EE AA BB GG
... and so on

I have come across the permutations function and the php shuffle function but i do not know how to modify them to suit the limitation of items per result set?

Community
  • 1
  • 1
rainerbrunotte
  • 907
  • 1
  • 17
  • 37

1 Answers1

0

Don't have time to code this up right now but one thing you might want to do is load 5 strings in an array and shuffle the array. Run a md5 sum on that and put it in a second array, if that md5 sum doesn't already exist before adding it to the md5 array, then its a unique shuffle.

Eric Van Joshnon
  • 191
  • 2
  • 13