Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
検討:
preg_match("#(.{100}$keywords.{100})#", strip_tags($description), $matches);
中央に検索文字列を配置して、両側に 100 文字のみを表示しようとしています。
このコードは実際に機能しますが、大文字と小文字が区別されます。大文字と小文字を区別しないようにするにはどうすればよいですか?
i区切り文字の後に修飾子を追加するだけ#です:
i
#
preg_match("#(.{100}$keywords.{100})#i", strip_tags($description), $matches);
修飾子が設定されている場合i、パターン内の文字は大文字と小文字の両方に一致します。
別のオプション:
<?php $n = preg_match('/(?i)we/', 'Wednesday'); echo $n;
https://php.net/regexp.reference.internal-options