I’m looking for a function that do the same as SQL LIKE statements :
$match = match('abcdefg', 'a_c*fg');
where “_” represent one char and “*” multiple.
I need to replace theses char with a regex part like “.+” for “*” but i should before it escape regex chars with preg_quote excepts theses two “_” and “*”.
Is there a simple way to do it ?
take a look at fnmatch function
OR
The next one, you can use strpos:
The next you can just use equals:
Of course, you can use regex for all of them:
to convert your patterns to regex, place a ^ at the beginning, and a $ at the end, then replace * with .* and escape .s.