I need to find out what is the best algorithm to generate a list of all combinations of an array in php.
I want all possible combinations of elements in the original Array. The duplicate question wants only permutations. The difference is that I want to include, for example, "22", while "22" is not in an element in the Array of permutations of this array.
Here is an example :
Input : 1, 2, 3
Then the output will be
Output : 1, 2, 3, 11, 12, 13, 21, 22, 23, 31, 32, 33, 111, 112, 113, 121, 123 ... until 333.
This question is different from Finding the subsets of an array in PHP, because this question wants all combinations of the array up to a certain length, not all permutations of the array up to a certain length. In particular, the linked question will for example never return "11" or "332" while this question wants to get these values as output as well.