If the subject is an array, str_ireplace() returns an array with the replacements applied to each element. For case-sensitive replacing, use str_replace() instead.
Items are paired by position: red becomes green, BLUE becomes yellow.
Case is ignored, so "Red" and "blue" still match.
PHP returns one final string with both changes.
Frequently Asked Questions
str_ireplace() finds a search value in a string and replaces it with another value, ignoring upper and lower case. It returns the new string and leaves the original unchanged.
str_replace() is case-sensitive, so "Cat" does not match "cat". str_ireplace() ignores case, so both match. Everything else works the same.
Pass a variable as the fourth argument. PHP stores the total number of replacements in it, for example str_ireplace('a', 'b', $text, $count).
Yes. If the subject is an array, PHP applies the replacements to every element and returns a new array. The search and replace values can also be arrays.
No. The replacement text is inserted exactly as you typed it. If you need to match the original case, use preg_replace_callback() with your own logic.