It's a confusion problem - so the wording may seem hard to follow. I'm likely over complicating a simple problem. Added an example question to help figure this out.
Example Question
Finding a 5 letter word from a database with the characters hxinenvarbav. I've organized the words in the DB to also contain a column of the word in alphabetical format. This means, the word "happy" has a column with the value "ahppy", so from the letters hxinenvarbav I can alphabetically organize them using the following code.
<?
$letters = str_split('hxinenvarbav'); asort($letters);
$letters = implode('',$letters); // returns 'aabehinnrvvx'
?>
The Issue
However, I can't simply search with mysql "LIKE '%aabehinnrvvx%' " and find 5 letter words with those characters, as obviously that will not pull any results. Unless maybe there is a MySQL query I could do? Maybe organize the column differently. I can however, use str_split($letters,5) to take 5 letters chunks of the 12 letter combination.
How would I go about, splitting in chunks each possible 5 letter combination from these 12 letters while keeping in mind, I need to query the table.
Does this make sense? Do I need to elaborate any further? Likely, I'm just over thinking and can't seem to simplify what it is I'm trying to accomplish. I have some complex mathematics that can find all possible combinations. But since I have placed in alphabetical order, I'm only searching combinations - not permutations. And on top of that, I don't need to as far as I logically believe, query 'each' combination. As there are 792 possible 5 letter combinations from only 12 letters (without calculating repeating characters). So 792 query calls is not nice - and 792 OR statements in my query, is clearly not an option. LOL!.
Any suggestions?
I did just think about searching via available characters left from alphabet - but, some words have repeating letters so that's not an option either.