I\'m doing a code that eliminates unneeded combinations such as I (ABCDE) do not want AAA BBB AB BA only want ABC ABD ABE .... so on, want it to be valid for any situation,
require_once 'Math/Combinatorics.php';
$combinatorics = new Math_Combinatorics;
$set = range(1,6);
$combosWithoutRepetition = $combinatorics->combinations($set, 3);
foreach ($combosWithoutRepetition as $combo) {
echo join(',', $combo), "\n";
}
http://pear.php.net/package/Math_Combinatorics
you don't need to install pear, you can just download that package and use it.