str_replace(find,replace,string,count)
<?php
echo str_replace("Java","PHP","Hello Java world!");
?>
Hello PHP world!
<?php
$arr = array("bule", "red", "green", "yellow");
print_r (str_replace("red","pink",$arr, $i));
echo "<br>";
echo "总共替换了 $i 个字符串";
echo "<br>";
?>
Array ( [0] => bule [1] => pink [2] => green [3] => yellow )
总共替换了 1 个字符串
<?php
$arr = array("bule", "red");
$arr2 = array("green");
$arr3 = array("bule", "red", "pink");
print_r (str_replace($arr, $arr2,$arr3 ));
?>
Array ( [0] => green [1] => [2] => pink )
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |