Example
Replace the character "WORLD" (case-insensitive) in String "Hello world!" with "Peter":
<?php echo str_ireplace("WORLD","Peter","Hello world!"); ?>
Definition And Usage
str_ireplace() function replaces some characters in a string (case insensitive).
This function must follow the following rules:
If the string searched is an array, then it will return an array.
If the searched string is an array, then it will find and replace each element in the array.
If an array needs to be searched and replaced at the same time, and the elements to be replaced are less than the number of found elements, the excess elements will be replaced with empty strings .
If you search an array and replace only one string, the replacement string will work for all found values.
Note: This function is not case sensitive. Please use the str_replace() function to perform a case-sensitive search.
Note: This function is binary safe.
Syntax
str_ireplace(find,replace,string,count)
Parameters | Description |
find | Required. Specifies the value to be found. |
replace | Required. Specifies the value to replace the value in find . |
string | Required. Specifies the string to be searched for. |
count | Optional. A variable that counts the number of substitutions. |
Technical details
Return value: | Returns a string with the replacement value or array. |
PHP Version: | 5+ |
##Update Log : | In PHP 5.0,added the count parameter. |