I have a bunch of strings in database, on which i'm hoping to use some kind of data structure, instead of doing an SQL "WHERE 'a b' LIKE 'a%'" kind of search.
(In real world example these can be up to 5000)
A - Let's say i have the words/needles: for, in, like, release
Note: these are always the same, the only thing that can happen here is to expand, but they don't change
(In real world example these can be up to 50)
B - Then i have the other words/haystacks: for people, in magazine, date of release, daily news
Note: These are dynamic, they are always different
I'd like to know of a good way to find/remove all the words from B, which start or end in any of the words from A
So the ones i would remove from the example, would be: for people, in magazine, date of release
I'm happy even with a generic idea, which i can implement in PHP
PS: I might go back to mysql if all the given ideas are slower, then using a mysql LIKE search, so i'd prefer something faster, or at least as fast as mysql
One solution i could think of would be to split the words from Bfor, people, in, magazine, date, of, release
Mark those that exist in Afor, in, release
This way we would end up with much smaller data and it would be fine to just do an strpos on them in a foreach loop
Let me know if you know of a better way.