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

Java代码翻译成PHP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:09:09
Original
2068 people have browsed it

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

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

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

回复内容:

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

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>
Copy after login
Related labels:
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template