Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-19-2007, 11:21 AM   PM User | #1
b_hole
Regular Coder

 
Join Date: Aug 2006
Posts: 135
Thanks: 0
Thanked 0 Times in 0 Posts
b_hole is an unknown quantity at this point
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?
b_hole is offline   Reply With Quote
Old 03-19-2007, 10:31 PM   PM User | #2
Inigoesdr
Super Moderator


 
Inigoesdr's Avatar
 
Join Date: Mar 2007
Location: Florida, USA
Posts: 3,601
Thanks: 2
Thanked 397 Times in 390 Posts
Inigoesdr is a jewel in the roughInigoesdr is a jewel in the roughInigoesdr is a jewel in the rough
What is that supposed to do exactly?
Inigoesdr is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:30 AM.


Advertisement
Log in to turn off these ads.