With the help of SO, I was able to make a regular expression for my purposes, it works great, but it completely ignores special characters.
$pattern='/(?=.*\b\Q'.str_replace(' ','\E\b)(?=.*\b\Q',$requestedservice).'\E\b)/i';
preg_match($pattern, $item)
Here $requestedservice
is the character that it's trying to match with $item
from the database.
The $item
is Walk - Dance
so if the $requestedservice
is Walk - Dance
as well, it's not matched, but if the $requestedservice
is Walk Dance
it is matched.
I am not sure why it's ignoring special characters like -
/
%
I am using html_entity_decode
for the $requestedservice
so that's not an issue.
Any guidance would be really helpful.