function ReplaceWord($str_replace,$str,$text)
{
if(!$str) return $text;
$text = str_replace($str_replace[count($str_replace)-1],$str[count($str)-1],$text);
unset($str[count($str)-1]);
unset($str_replace[count($str_replace)-1]);
$text = ReplaceWord($str,$str_replace,$text);
return $text;
}

解决方案 »

  1.   

    传入的 $str_replace,$str 是数组
    参与替换的 $str_replace[count($str_replace)-1],$str[count($str)-1] 是单值
    如果要按数组对应替换则 $text = str_replace($str_replace,$str,$text);
    否则需多次执行直至 $str 为空
      

  2.   

    传入的 $str_replace,$str 是数组
    参与替换的 $str_replace[count($str_replace)-1],$str[count($str)-1] 是单值
    如果要按数组对应替换则 $text = str_replace($str_replace,$str,$text);
    否则需多次执行直至 $str 为空
      

  3.   


    我用数组的方式也试过了,每次修改的数量都是0,反而用字符串的方式每次都是有一个字符串可以修改,其他的就不修改了,但是把参数$str[count($str)-1]和$str_replace[count($str_replace)-1]直接写他们的值填进去就可以执行,这个不知道是什么情况
      

  4.   

    如果传入的参数不是数组,那么 count 只能是 1,肯定是不对了的
      

  5.   

    function ReplaceWord(&$str_replace,&$str,$text)
      

  6.   

    foreach($r as $key=>$value)
    {
    $rr = explode("|",$value);
    $text = str_replace($rr[0],$rr[1],$text);
    echo $text;
    }
    就这么写,每次都是只有第一条是成功的,后面的都没有替换成功,哪怕我把数组元素的顺序改变还是只有第一个元素是被替换成功,后面几个都么有被替换