PHP str_ireplace() 函数使用一个字符串替换字符串中的另一些字符。
<?php
$find = "anyang";
$replace = "安阳";
$arr = "anyang测试anyang";
$newstr = str_ireplace($find,$replace,$arr);
echo $newstr;
?>
使用这个str_ireplace()就能替换了,而且还不用担心大小写问题,如果不用考虑大小写那就使用str_replace()即可!
参数如下:
str_ireplace(find,replace,string,count)
参数 描述
find 必需。规定要查找的值。
replace 必需。规定替换 find 中的值的值。
string 必需。规定被搜索的字符串。
count 可选。一个变量,对替换数进行计数。
欢迎采纳!
参考资料:璞玉