I've got a string with spaces. I need to split (explode) it and got all variants of sequences from it. For example:
string1 string2 string3
I need to parse it and get an output like this:
string1 string2 string3 string1 string3 string2 string2 string1 string3 string2 string3 string1 string3 string2 string1 string3 string1 string2
What's the most efficient way to do this?
EDIT: actually i need to parse maximum of 3 strings. So i'm doing this not a pretty way (hardcoded):
$exploded_query = explode(' ', $query); if(count($exploded_query) == 2) { //2 variants } if(count($exploded_query) == 3) { //6 variants }
So i'm looking for some pretty way to do it.