How do I make this preg_match case insensitive?
Just add the i
modifier after your delimiter (#
in your case):
preg_match("#(.{100}$keywords.{100})#i", strip_tags($description), $matches);
If your delimiter is /
, add an i
after it :
preg_match("/your_regexp_here/i", $s, $matches); // i means case insensitive
If the i
modifier is set, letters in the pattern match both upper and lower case letters.
Another option:
<?php
$n = preg_match('/(?i)we/', 'Wednesday');
echo $n;
https://php.net/regexp.reference.internal-options