Hmmmmm, did I release that to the public domain?
Not to complicate issues, but I thought you might be interested.
REGEXP has an 'or' function (but not an 'and' - bummer -). You can separate each search item with a | (pipe) symbol.
So rather than looping through the array and creating multiple REGEXP you can create it in one shot outside of your array loop like so:
PHP Code:
$strProdNameSearch = " concat(' ',pd.products_name,' ') REGEXP '[^a-zA-Z]+".join('[^a-zA-Z]+|[^a-zA-Z]+',$search_keywords)."[^a-zA-Z]+' ";
This will enhance the speed on searches with numerous search items.
Also of note, while I took the easy way out:
\b allows you to perform a "whole words only" search using a regular expression in the form of \bword\b.
So, I think
PHP Code:
REGEXP '[^a-zA-Z]+$search_keywords[$i][^a-zA-Z]+'
could also be written as
PHP Code:
REGEXP '\b$search_keywords[$i]\b'
$strProdNameSearch = " concat(' ',pd.products_name,' ') REGEXP '\b+".join('\b|\b',$search_keywords)."\b' ";