在php中字符替换函数有几个如有:str_replace、substr_replace、preg_replace、preg_split、str_split等函数,下面我来给大家总结介绍介绍....参数 描述
find 必需,规定要查找的值.
replace 必需,规定替换 find 中的值的值.
string 必需,规定被搜索的字符串.
count 可选,一个变量,对替换数进行计数....在本例中,我们将演示带有数组和 count 变量的 str_replace() 函数,代码如下:
$arr=array(“blue”,”red”,”green”,”yellow”);
print_r(str_replace...正数 – 被替换的字符串长度
负数 – 从字符串末端开始的被替换字符数
0 – 插入而非替换
例子,代码如下:
echosubstr_replace(“Hello world”,”earth”,6);...pattern 必需,需要搜索的模式.
replacement 必需,用于替换的字符串或数组.
subject 必需,需要替换的字符串或数组.
limit 替换的次数,-1为无限
count 完成替换的次数,变量