All possible combinations algorithm

Dan Wilson dan at
Tue Jun 14 23:03:29 MDT 2005

Ok folks, I need the help of some good mathematicians/programmers.  I
know some of you are very good with this type of stuff and I am not.

Given an array of elements (with an unknown length), I need to find all
possible combinations of that array.  Say I have an array with the
values of:

'hey', 'you', and 'guys'

I need an algorithm that allows me to combine each of these array
elements into a string... all combinations:

"hey you guys"
"hey guys you"
"you hey guys"
"you guys hey"
"guys hey you"
"guys you hey"

I'm sure I could pound this out, but I'm sure some of you have done this
in the past or know a specific algorithm that would do the trick.



PS. This is for PHP, so if you have code examples, that would be even

More information about the PLUG mailing list