I've had this problem bending my mind for a while now (head cold doesn't help either!), basically I have a PHP array which looks like this example:
$array = 'apples'; $array = 'pears'; $array = 'oranges'; $array = 'steve'; $array = 'bob';
And I would like to be able to produce from this a table with every possible combination of these, but without repeating any combinations (regardless of their position), so for example this would output
Array 0 Array 1 apples steve apples bob pears steve pears bob
But I would like for this to be able to work with as many different arrays as possible.
this is called "cartesian product", php man page on arrays http://php.net/manual/en/ref.array.php shows some implementations (in comments).
and here's yet another one: