Why would this code
$my_replacements = array("my dog", "doga");
$my_string = "doga my dog test";
$my_patterns = array_map(function($my_text) { return "/(^|[\n\r\f\t \.\,])" . trim($my_text) . "([\n\r\f\t \.\,]|$)/iu"; }, $my_replacements);
$replaced_string = preg_replace($my_patterns, '', $my_string);
echo $replaced_string;
return dogatest instead of test?
but if my_string is changed to "my dog doga test", it replaces correctly both elements in my_replacements?
What I want to accomplish is that, given a string, find all the strings that are in $my_replacements and delete them from the string. Taking into account the /u modifier and /i modifier or a preg_replace, because it can happen that the substring is in uppercase, and it has to be deleted either way.
my_patternsarray? Also what value does$my_texthas?