Instance
Replace the character "world" in the string "Hello world!" with "Shanghai":
<?phpecho Str_replace ("World", "Shanghai", "Hello world!");? >Definition and usage
The Str_replace () function replaces some characters in a string with other characters (case-sensitive).
The function must adhere to the following rules:
- If the searched string is an array, it returns the array.
- If the searched string is an array, it will find and replace each element in the group.
- If you need to find and replace an array at the same time, and you need to execute the replacement element less than the number of elements found, the extra element is replaced with an empty string
- If you are looking for an array, instead of a string, the substitution string will work for all found values.
Note: The function is case-sensitive. Use the Str_ireplace () function to perform a case-insensitive search.
Note: This function is binary safe.
PHP Replacement String-str_replace