Case insensitive preg_replace_callback

前端 未结 5 1072
忘了有多久
忘了有多久 2021-01-26 03:48

In the function below, I want to match the keyword case insensitive (should match \"Blue Yoga Mats\" and \"blue yoga mats\")...

However, it currently only matches if the

5条回答
  •  天涯浪人
    2021-01-26 04:13

    Use the /i modifier:

    $post->post_content = preg_replace_callback("/\b($mykeyword)\b/i","doReplace", $post->post_content);
    

提交回复
热议问题