PHP 函数:str_replace()

字符串取代。

语法: string str_replace(string needle, string str, string haystack);

返回值: 字符串

函数种类: 资料处理

内容说明
本函数将字符串 str 代入 haystack 字符串中,将所有的 needle 置换成 str。[email protected] (11-Apr-1999) 指出在 PHP 3.0.7 版,本函数有些 bug,而 [email protected] (05-Jun-1999) 补充在 PHP 3.0.8 版本函数就回复正常了。

使用范例
下例将 %body% 以 black 取代

<?php $bodytag = str_replace("%body%", "black", ""); echo $bodytag; ?>