To replace characters in an existing string:

$new_string = str_replace (‘b’,'a’,$string);

a = text you want to find
b = text you want to replace
$string = string you want to find

Example:

$string = ‘I love apples’

$new_string = str_replace (‘orange’,'apples’,$string);

Result of the new string will be:

I love orange