I have a function in php which I would like to perform a simple search on a string, using a kw as the search phrase, and return true if found.
This is what I have no
You can use word boundaries \b:
\b
if (preg_match("/\b".preg_quote($kw_to_search_for)."\b/i", $search_strings[$i])) { // found }
For instance:
echo preg_match("/\bProfessional\b/i", 'Prof'); // 0 echo preg_match("/\bProf\b/i", 'Prof'); // 1
/i modifier makes it case insensitive.
/i