
str_replace 함수의 첫 번째 인수는 교체할 문자열을 지정할 때, 문자열 내에 특정 문자열을 포함하고자 할 때는 다음과 같이 사용할 수 있습니다.
- 특정 문자열을 포함하는 문자열을 교체할 때는, 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
$original_string = "Hello, world!";
$target_string = "world";
$replacement_string = "earth";
$replaced_string = str_replace($target_string, $replacement_string, $original_string);
echo $replaced_string; // Hello, earth!
- 특정 문자열을 포함하는 문자열을 교체할 때는, 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
$original_string = "Hello, world!";
$target_string = "Hello, ";
$replacement_string = "Hi, ";
$replaced_string = str_replace($target_string, $replacement_string, $original_string);
echo $replaced_string; // Hi, world!
- 특정 문자열을 포함하는 문자열을 교체할 때는, 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
$original_string = "Hello, world!";
$target_string = "Hello, world!";
$replacement_string = "Hi, earth!";
$replaced_string = str_replace($target_string, $replacement_string, $original_string);
echo $replaced_string; // Hi, earth!
2025-04-30 04:13