Possible Duplicates:
PHP: How to get all possible combinations of 1D array?
Generate all possible combinations using a set of strings
$s = 'A,B,C';
Given a set of strings, how do you compute that it's possible to have AAA BBB CCC ABC ACB BCA etc.?