unique permutations of variable length [duplicate]
问题 This question already has answers here : Finding the subsets of an array in PHP (4 answers) Closed 6 years ago . I need to get an array of unique permutations of any length: array of values: a, b, c, d, e, f, g, h, i, j, k, l, m (13 total) expected result: a, b, c, ab, ac, bc, abc, .... ab == ba (duplicate) abc == acb == bca == bac == ... (duplicates) What I have so far is kind of a brute force attack at it, but with 13 elements this is kind of optimistic. I need something smarter,