1 str_replace 函数
- 使用
str_replace(find,replace,string,count)
常见用法
$arr = array("blue","red","green","yellow");
print_r(str_replace("red","pink",$arr,$i));
echo "替换数:$i";
高级用法(批量替换)
$find = array("Hello","world");
$replace = array("B","A");
$arr = array("Hello world","world","!");
$str = "Hello world danbus world";
print_r(str_replace($find,$replace,$arr));
print_r(str_replace($find,$replace,$str));
/**
Array
(
[0] => B A
[1] => A
[2] => !
)
-------------------
B A danbus A
**/