实例

把字符串 "Hello world!" 中的字符 "world" 替换为 "Shanghai":

<"world","Shanghai","Hello world!");
"htmlcode">
<"blue","red","green","yellow");
print_r(str_replace("red","pink",$arr,$i));
echo "Replacements: $i";
"htmlcode">
<"Hello","world");
$replace = array("B");
$arr = array("Hello","world","!");
print_r(str_replace($find,$replace,$arr));
"htmlcode">
<"color: #ff0000">user_order_list 替换为user/order_list

<"htmlcode">
<"color: #0000ff">例子:

<?php 
$str = 'user_order_list'; 
echo str_replace_limit('_', '/', $str, 1); // user/order_list 
$arr = array('abbc','bbac','cbba'); 
$result = str_replace_limit('b', 'B', $arr, 1); 
print_r($result); // Array ( [0] => aBbc [1] => Bbac [2] => cBba ) 
?> 

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持!

华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com