首页 >后端开发 >php教程 >用str_replace轮换数组时有点怪

用str_replace轮换数组时有点怪

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原创
2016-06-13 11:40:41867浏览

用str_replace替换数组时有点怪

$str = '2abc';<br />$arr1 = array('0', '1', '2', '3', '4', '5', '6');<br />$arr2 = array('9', '8', '7', '6', '5', '4', '3');<br />$str = str_replace($arr1, $arr2, $str);<br />echo $str;<br />//输出结果正常:7abc

$str = '2abc';<br />$arr1 = array('0', '1', '2', '3', '4', '5', '6', '7');<br />$arr2 = array('9', '8', '7', '6', '5', '4', '3', 'W');<br />$str = str_replace($arr1, $arr2, $str);<br />echo $str;<br />//输出结果有误:Wabc

请问为什么会这样啊?
谢谢!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn