PHP str_replace是否有超过13个字符的限制?

use*_*651 2 php compiler-errors str-replace

直到第13个字符被击中为止.一旦str_ireplace在cyper数组中命中"a",str_ireplace就会停止工作.

数组的大小是否有限制?请记住,如果键入"abgf",我会得到"nots",但如果我输入"abgrf",当我得到"注释"时,我会得到"notrs".我的大脑无法弄明白.

$_cypher = array("n","o","p","q","r","s","t","u","v","w","x","y","z","a","b","c","d","e","f","g","h","i","j","k","l","m");

$_needle = 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");


$_decryptedText = str_ireplace($_cypher, $_needle, $_text);
echo $_decryptedText;
Run Code Online (Sandbox Code Playgroud)

救命?

hak*_*kre 5

使用strtr文档:

$_text = 'abgrf';

$translate = array_combine($_cypher, $_needle);

$_decryptedText = strtr($_text, $translate);

echo $_decryptedText; # notes
Run Code Online (Sandbox Code Playgroud)

演示


但是,有什么我做错了吗?

它将替换每对,一对接一个已经被替换的字符串.因此,如果您替换再次替换的字符,可能会发生这种情况:

    r -> e   e -> r
abgrf -> notes -> notrs
Run Code Online (Sandbox Code Playgroud)

您的替换后,您的电子更换.