The str_replace() function replaces some characters with some other characters in a string.
This function replaces all occurrences of the search string in the main string with the replace string. Let's look at the example below.
The first parameter is what you are searching for replace, the second parameter is a string of replace with, and the third parameter is the string you want searched. All three parameters can use an array as input if desired.
<?php $str = "Hello! How are you today?"; echo str_replace("Hello", "Hi", $str); ?>
In the above example, replace the "Hello" with "Hi" in string $str. The above code will output "Hi! How are you today?".