如果字符串中没有中文可以使用str_replace()函数替换字符串。

语法格式:

str_replace(find,replace,string,count)

参数介绍:

实例:

把字符串 "Hello world!" 中的字符 "world" 替换为 "Shanghai"

echo str_replace("world","Shanghai","Hello world!");

以上就是php中的字符串替换函数是什么的详细内容,更多请关注亿速云其它相关文章!