str_replace

(PHP 3>= 3.0.6, PHP 4 )

str_replace --  haystack 의 모든 needle을 str로 변환한다.

설명

string str_replace ( string needle, string str, string haystack)

이 함수는 haystackneedle을 주어진 str로 바꾼다. (This function replaces all occurences of needle in haystack with the given str.) 만약 복잡한 치환 룰이 필요하지 않다면, ereg_replace() 대신 이 함수를 사용하여도 된다.

예 1. str_replace()

$bodytag = str_replace ("%body%", "black", "<body text=%body%>");

이 함수는 binary safe.

참고: str_replace()는 PHP 3.0.6,에서 추가되었지만, PHP 3.0.8 에 버그가 수정되었다.

ereg_replace() 그리고 strtr()을 참고하라.