2
Follows the code:
$minu = range("a", "z");
$maiu = range("A", "Z");
$letras = array_merge($minu, $maiu);
$minusculas = array_merge($minu, $maiu);
By making a str_replace($Lminusculas, $Lmaiusculas, "TesteSimples");
the following is returned:
lerveSimvses
And by making a str_replace($Lmaiusculas, $Lminusculas, "lerveSimvses");
the following is returned:
Tisteruephes
However, I wanted to do that by doing the second str_replace()
to string returned to initial state Testesimples.
(naturally, this "encryption" will choke if the string has accented characters)
– user25930
You will not have accented characters, only minute and upper case, @ctgpi. Regarding your answer, my intention is rather to "encrypt" the string. I changed my
str_replace
forstrtr
but neither "encryption" nor "decryption". Remembering that my code remains the same as the question, only replaces the functions (str_replace
forstrtr
).– Igor
To
strtr
with three parameters accepts strings, not arrays, and the order of the parameters is different; you will have toimplode
go to the arrays before calling thestrtr
, that even I didn’t do in my code.– user25930
Ah, that’s right! The
implode
, worked perfectly! Thank you!– Igor