<?php
echo str_replace("world","Shanghai","Hello world!");
?>
意思: 在 Hello world! 查找 world 并且替换为shagnhai
参数 描述
find 必需。规定要查找的值。
replace 必需。规定替换 find 中的值的值。
string 必需。规定被搜索的字符串。
count 可选。对替换数进行计数的变量。
输出如下:
Hello Shanghai!
<?php
echo str_replace("world","Shanghai","Hello world!");
?>
意思: 在 Hello world! 查找 world 并且替换为shagnhai
参数 描述
find 必需。规定要查找的值。
replace 必需。规定替换 find 中的值的值。
string 必需。规定被搜索的字符串。
count 可选。对替换数进行计数的变量。
输出如下:
Hello Shanghai!