Just had a look at your example, it might be an idea for to add the ability to enable case insensitive searches as well (your current example is case sensitive)
Just a note, php has absolutely no knowledge that the data has come from a textbox. All it knows is that it has certain data held in a variable.
Just had a look at your example, it might be an idea for to add the ability to enable case insensitive searches as well (your current example is case sensitive)
there is no string to lower function used in your example.
Ideally you should encompass the script within a function. You could make the function have 2 inputs the 1st for the data and the second an optional 1 for case. Then simply use an if statement to determine if it is case sensitive.
Using the stripslashes and htmlentities is not necessary within the function as they are unrelated to the problem.
You have stripped slashes in your example but you never checked magic_quotes_gpc was enabled. If it is not then you are trying to strip valid data which could cause unexpected output (if the input was meant to contain a slash for example you would have removed it)
Also when testing I noticed from your example that “the is 1 entry and as” is another was this as intended (i left the behavior in my example).
Of course if you wish the function to output the words as a string then it would be easy to do but I left it as an array for now.