$str = 'Hello, world!';
$new_str = str_replace('world!', 'universe!', $str);
echo $new_str;
결과 출력
str_replace(
    array|string $search,
    array|string $replace,
    string|array $subject,
    int &$count = null
): string|array

// str_replace(찾을 문자열, 바꿀 문자열, 대상 문자열[,카운트]);
$original_string = 'Hello, world! Hello, PHP!';
$new_string = str_replace('Hello', 'Hi', $original_string);

echo $new_string;  // 출력: 'Hi, world! Hi, PHP!'
$str = 'This is a test';
$new_str = str_replace('test', '', $str);
echo $new_str; // 출력: 'This is a'
$original_array = ['Apples are red.', 'Bananas are yellow.', 'Apples and bananas are delicious.'];

$search = ['Apples', 'Bananas'];
$replace = ['Oranges', 'Grapes'];

$new_array = str_replace($search, $replace, $original_array);

print_r($new_array);

/* 출력:
Array
(
    [0] => Oranges are red.
    [1] => Grapes are yellow.
    [2] => Oranges and grapes are delicious.
)
*/
$original_string = 'Apples are red. Bananas are yellow. Apples and bananas are delicious.';

$search = ['Apples', 'Bananas'];
$replace = ['Oranges', 'Grapes'];

$new_string = str_replace($search, $replace, $original_string);

echo $new_string;
// 출력: 'Oranges are red. Grapes are yellow. Oranges and grapes are delicious.'
$original_string = '안녕하세요, 세상! 안녕하세요, PHP! 안녕하세요, 모두!';
$search = '안녕하세요';
$replace = '안녕';
$count = 0;

$new_string = str_replace($search, $replace, $original_string, $count);

echo $new_string;  // 출력: '안녕, 세상! 안녕, PHP! 안녕, 모두!'
echo "단어 '{$search}'은(는) {$count}번 나타납니다.";
// 출력: "단어 '안녕하세요'은(는) 3번 나타납니다."