← All built-ins / str_replace()

str_replace()

str_replace(...$args): string

Parameters

NameTypeDescription
$searchstringsubstring to find
$replacestringreplacement for every occurrence
$subjectstringstring 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

See also

preg_replace()substr()