I want to have a short and easy way to replace the character A to B, B to C, Z to A,... in PHP.
I already have tried this:
$pwd = "Abc";
for($char = ord('A'); $char <= ord('Z'); $char++) {
$newc = $char+1;
if($newc > 90)
$newc = 65;
$pwd = str_replace(chr($char), chr($newc), $pwd);
$pwd = str_replace(chr($char+32), chr($newc+32), $pwd);
}
echo $pwd;
But when I use it I only get "Aaa"... :(
I can't find anything on the internet. Could you maybe help me?
Thanks in advance, Luuc
Aucun commentaire:
Enregistrer un commentaire