str_replace
子字符串替换
<p><strong>适用PHP版本:</strong>PHP 4及以上版本</p>
<h2>函数说明</h2>
<p>str_replace 函数用于在字符串中查找并替换指定的内容。该函数会搜索字符串中的所有匹配项,并用指定的替换字符串来替代它们。</p>
<h2>函数语法</h2>
<p>str_replace(mixed $search, mixed $replace, mixed $subject[, int &$count = null])
在上面的示例中,str_replace 函数将字符串 "I have an apple and another apple." 中的所有“apple”替换成了“orange”,最终输出的结果是:
I have an orange and another orange.