Since str_replace is binary safe and UTF-8 is bijective encoding, you can use str_replace even if the search string or replacement contains multi-byte characters if all three parameters are encoded as UTF-8.
In this case, there is no mb_str_replace function.
If your encoding is not bijective, i.e. there are several representations of the same line, for example < in UTF-7, which can be expressed as '+ADw-' and '<' , you need to convert all the lines to the same (bijective) encoding, apply str_replace , and then convert strings in the target encoding.
source share