I'm trying to create a script that, based on an input a??
creates an array of all the combinations and permutations of all words containing an a
and two other characters from the alphabet.
Values are such as a
, ab
, ba
, dab
, bga
etc - as you may see the array contains (or should contain) a weird amount of values.
The problem is that the functions I use in the script outputs even more values with many duplicates.
And for some reason I can not create a flattened array without duplicates. I tried to use array_unique()
but it doesn't work here. I tried to use explode()
and implode()
to flatten the result array, but no success. Even if I succeed to create a string from the values, when I try to transform this string into an array, the result is again the actual multi-dimensional array.
This drives me crazy, and as you see the code, I'm a beginner in PHP.
Any help to transform the actual multidimensional array to a flattened one without duplicates is highly appreciated. An example: actually the array contains 12168 sub-arrays, and only the string a
occurs 1456 times. What I need is an array that doesn't have sub-arrays and contains each results only one time.