dimanche 21 décembre 2014

Shuffle and randomize string without repeat in PHP

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?





Aucun commentaire:

Enregistrer un commentaire