str_replace替换的四种方式-数组替换数组

代码语言:php

所属分类:数组

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<?php
//实例一:字符串替换字符串
$str1 = str_replace("red", "black", "red green yellow pink purple");
echo $str1.""; //输出结果为black green yellow pink purple
?>
<?php
//实例二:字符串替换数组键值
$arr = array("blue", "red", "green", "yellow");
$str1 = str_replace("red", "pink", $arr, $i);
print_r($str1);
?>
<?php
//实例三:数组替换数组,映射替换
$arr1 = array("banana", "orange");
$arr2 = array("pitaya", "tomato");
$con_arr = array("apple".........完整代码请登录后点击上方下载按钮下载查看

网友评论0