Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2006
    Posts
    135
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help converting JS to PHP

    Hi,

    I'm trying to convert some JS functions to PHP.
    My main problem is tyhat I didn't wrote the JS, so I'm not fully understand it.

    Anyway, here's a given JS function for example:
    Code:
    a -= b; a -= c; a ^= (zeroFill(c,13));
    b -= c; b -= a; b ^= (a<<8);
    c -= a; c -= b; c ^= (zeroFill(b,13));
    a -= b; a -= c; a ^= (zeroFill(c,12));
    b -= c; b -= a; b ^= (a<<16);
    c -= a; c -= b; c ^= (zeroFill(b,5));
    a -= b; a -= c; a ^= (zeroFill(c,3));
    b -= c; b -= a; b ^= (a<<10);
    c -= a; c -= b; c ^= (zeroFill(b,15));
    var ret = new Array(a,b,c);
    My PHP is this:
    PHP Code:
    $a=$a $b;
    $a=$a $c;
    $a=$a ^ (zeroFill($c13));
    $b=$b $c;
    $b=$b $a;
    $b=$b ^ ($a<<8);
    $c=$c $a;
    $c=$c $b;
    $c=$c ^ (zeroFill($b13));
    $a=$a $b;
    $a=$a $c;
    $a=$a ^ (zeroFill($c12));
    $b=$b $c;
    $b=$b $a;
    $b=$b ^ ($a<<16);
    $c=$c $a;
    $c=$c $b;
    $c=$c ^ (zeroFill($b5));
    $a=$a $b;
    $a=$a $c;
    $a=$a ^ (zeroFill($c3));
    $b=$b $c;
    $b=$b $a;
    $b=$b ^ ($a<<10);
    $c=$c $a;
    $c=$c $b;
    $c=$c ^ (zeroFill($b15));
    $ret=Array($a$b$c); 
    I can't see a reason for, but ret and $ret are not the same (checked using a loop to print all values).
    Help please?

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    What is that supposed to do exactly?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •