I need to filter the_content/the_excerpt and search & replace the following prepared array:
$searchArray = array("foo", "bar", "foo bar", ...);
My problem is the fact, that using php's str_replace() function it doesn't replace trailing strings like "foo bar". Instead it replaces only the "foo" without checking for the "foo bar" to be replaced. I understand why but I'm not sure how to solve this?
$content = str_replace(array_keys($searchArray), $replaceArray, $content); add_filter('the_content', 'my_search_and_replace_function');