Ask experts for an algorithm that combines all array elements.
Array:
$ Arr = array (A, B, C );
Required output:
A
AB
AC
ABC
B
BA
BC
C
CA
CB
It is to output all the combinations of array elements. The order is not required. you only need to be able to input all the elements.
Reply to discussion (solution)
An ACB, BAC, BCA, CAB, and CBA will also be output.
That is
Array ([0] => A [1] => AB [2] => AC [3] => ABC [4] => ACB [5] => B [6] => BA [7] => BC [8] => BAC [9] => BCA [10] => C [11] => CA [12] => CB [13] => CBA [14] => CAB)
What happened to Deere? Please refer to the essence area
$ Ar = array ('A', 'B', 'C'); $ res = array_chunk ($ ar, 1); for ($ I = 1; $ I
Array
(
[0] =>
[1] => B
[2] => C
[3] => AB
[4] => AC
[5] => BA
[6] => BC
[7] => CA
[8] => CB
[9] => ABC
[10] => ACB
[11] => BAC
[12] => BCA
[13] => CAB
[14] => CBA
)
0) {for ($ I = 0; $ I