← All built-ins / str_replace()
str_replace()
str_replace(...$args): string
Parameters
| Name | Type | Description |
|---|---|---|
| $search | string | substring to find |
| $replace | string | replacement for every occurrence |
| $subject | string | string to modify |
Return value
The string with every occurrence of $search replaced by $replace.
Example
echo str_replace("world", "HolyPHP", "hello world"), "
";
echo str_replace("aa", "b", "aaaa"), "
";hello HolyPHP bb