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
Simply add the i
modifier to your regex to make it perform a case insensitive match:
"/\b($mykeyword)\b/i"
By the way, if you haven't already, you need to escape special regex characters from your keyword. In case any are present, they could screw up your regex and cause PHP warnings/errors. Call preg_quote() before you perform the replacement:
$mykeyword_escaped = preg_quote($mykeyword, '/');
$post->post_content = preg_replace_callback("/\b($mykeyword_escaped)\b/i","doReplace", $post->post_content);