0

I looked for almost 2 hours on the Internet but I didn't find quite the solution that I was looking for.

So this is my problem. I am trying to get all permutation of elements in an array. But the result must be in one array and not only string. Every elements of the array must keep their respective keys.

For exemple, my array looks like this : $array = array('player1', 'player2', 'player3')

The result must be in an array for each permutation:

Exemple of expected results :

Array ( [0] => player1 [1] => player2 [2] => player3 )
Array ( [0] => player1 [1] => player3 [3] => player2 )
Array ( [1] => player2 [2] => player3 [0] => player1 )
Array ( [1] => player2 [0] => player1 [2] => player3 )
etc.

Note that there is no limit of players.

Thank you for your help !

(sorry for my bad english)

0 Answers0