preg_match("#(.{100}$keywords.{100})#", strip_tags($description), $matches);
我试图在每一侧只显示100个字符,中间有搜索字符串。
此代码实际上有效,但它区分大小写,我如何使其不区分大小写?
答案 0 :(得分:87)
只需在分隔符i
后添加 #
修饰符:
preg_match("#(.{100}$keywords.{100})#i", strip_tags($description), $matches);
如果设置了 i
修饰符,则模式中的字母会匹配大写和小写字母。
答案 1 :(得分:1)
另一个选择:
<?php
$n = preg_match('/(?i)we/', 'Wednesday');
echo $n;