【发布时间】:2012-12-05 03:26:53
【问题描述】:
我在使用数组时遇到了 PHP 函数 str_replace 的一些问题。
我有这条消息:
$message = strtolower("L rzzo rwldd ty esp mtdsza'd szdepw ty esp opgtw'd dple");
我正在尝试像这样使用str_replace:
$new_message = str_replace(
array('l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','a','b','c','d','e','f','g','h','i','j','k'),
array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'),
$message);
结果应该是A good glass in the bishop's hostel in the devil's seat,但我得到的是p voos vlpss xn twt qxswop's wosttl xn twt stvxl's stpt。
但是,当我只尝试替换 2 个字母时,它会很好地替换它们:
$new_message = str_replace(array('l','p'), array('a','e'), $message);
字母 l 和 p 将替换为 a 和 e。
如果它们的大小完全相同,为什么它不能与完整的字母数组一起使用?
【问题讨论】:
标签: php arrays str-replace