pofpof98
asked on
what is the code for rot13 in php
hello
Is it possible to get the following java code in php code
String s = args[0];
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c >= 'a' && c <= 'm') c += 13;
else if (c >= 'n' && c <= 'z') c -= 13;
else if (c >= 'A' && c <= 'M') c += 13;
else if (c >= 'A' && c <= 'Z') c -= 13;
System.out.print(c);
}
thanks
regards
Is it possible to get the following java code in php code
String s = args[0];
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c >= 'a' && c <= 'm') c += 13;
else if (c >= 'n' && c <= 'z') c -= 13;
else if (c >= 'A' && c <= 'M') c += 13;
else if (c >= 'A' && c <= 'Z') c -= 13;
System.out.print(c);
}
thanks
regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:-)
if ($string) {
for($i=0;$i<strlen($string
$j=ord($string[$i]);
if ((($j>=ord("n")) & ($j<=ord("z"))) | ($j>=ord("N")) & ($j<=ord("Z"))) {
$j=$j-13;
}
elseif ((($j>=ord("a")) & ($j<=ord("m"))) | ($j>=ord("A")) & ($j<=ord("M"))) {
$j=$j+13;
}
$new.=chr($j);
}
echo "<b>rot13</b>: $new";
}
?>
<br>
<form action=rot13.phtml>
<input name=string>
</form>