Home >Backend Development >PHP Tutorial >Java代码翻译成PHP

Java代码翻译成PHP

WBOY
WBOYOriginal
2016-06-06 20:09:091986browse

<code>char[] arr = str.toCharArray();
        // 加密
        for (int i = 0; i </code>

Java的toCharArray和PHP的explode转换结果完全不一样啊。。。

实在是不懂java,求大神帮忙把代码翻译成PHP的。感激不尽。

回复内容:

<code>char[] arr = str.toCharArray();
        // 加密
        for (int i = 0; i </code>

Java的toCharArray和PHP的explode转换结果完全不一样啊。。。

实在是不懂java,求大神帮忙把代码翻译成PHP的。感激不尽。

<code><?php $str="java to php";

$arr=array_values(unpack("c*",$str));
$len=strlen($str);
$out='';
for (  $i = 0; $i < $len; $i++) {
            $arr[$i] ^= 33;
            $arr[$i] ^= 17;
            $arr[$i] ^= 49;
            if ($i % 2 == 0) {
                $arr[$i] ^= 79;
            }
            if ($i % 3 == 0) {
                $arr[$i] ^= 11;
            }
            $out.=chr($arr[$i]);
        }

echo $out;
</code></code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn