Is there any function in PHP equal to SQL's %like%?
E.g.
$a = 'I drove the Car';
$b = 'i_drove_the_car';
if(like($a, $b))
{
echo "The strings have an %like% match";
}
Use strstr, or, if you want case insensitive, stristr:
if(strstr($a, $b)) {
echo "$b is in $a";
}
You can use regular expression, i.e. preg_match.
if (preg_match('#.*' . $b . '.*#/i', $a)) {
echo 'smth';
}
Option i means case insensetive mathcing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With