日常使用中使用字符串匹配函数,用的比较多的是str_replace()函数,这个函数是不区分大小写的。如果要区分大小写匹配检索可以使用str_ireplace()函数,用法两个函数完全一样。
1、概念
str_replace() 函数以其他字符替换字符串中的一些字符(区分大小写)。
该函数区分大小写。请使用 str_ireplace() 函数执行不区分大小写的搜索。
2、语法
把字符串 "Hello world!" 中的字符 "world" 替换成 "Peter":
echo str_replace("world","Peter","Hello world!");
返回:Hello Peter!。
3、参数
find、replace、string、count
4、返回值
返回带有替换值的字符串或数组。
5、实例
创建一个php示例文件;然后通过“tr_replace($vowels, "","hello world of php");”方法替换多个字符串即可。