Getting all possible order variations of array
Posted: Thu Mar 13, 2008 1:08 pm
Is there an existing function or can someone think of a good way to get all possible variations of the order of elements in an array? By this I mean, if I had an array like this:
I would run it through the function and get:
Code: Select all
array(1,2,3,4);Code: Select all
array(
array(1,2,3,4);
array(1,3,2,4);
array(1,3,4,2);
array(1,4,2,3);
array(1,4,3,2);
array(2,3,4,1);
...
)