[PHP] Re: PHP function unpack

2009-10-15 Thread Gabriel Hahmann
Hi,

I've sent this mail a few days ago, but as this list have a very high
traffic maybe my mail disappear from you inbox.

Any help would be appreciated.

Thanks in advance,
Gabriel.

On Sun, Oct 11, 2009 at 4:42 PM, Gabriel Hahmann
gabriel.hahm...@gmail.com wrote:
 Hi,

 I'm new to the list and I've search internet and didn't find an answer
 to my problem.

 I'm converting a perl script to PHP and I've done almost everything.
 The only part of the code that I didn't get working on PHP was:

 (PERL CODE)
 foreach ($b_length,$b_mac,$b_crlf,$b_crlf,$a_body) {
        $d_checksum += unpack(%16n*, $_);
 }

 The idea is to make a 16-bit checksum of all elements
 ($b_length,$b_mac,$b_crlf,$b_crlf,$a_body).

 I'm tried translating the code to:

 $arr_checksum = array($b_length,$b_mac,$b_crlf,$b_crlf,$File_Content);

 $d_checksum = 0;
 foreach($arr_checksum as $check_elem){
        $d_check = unpack(n*, $check_elem);
        for ($i=0;$i4;$i++){
                $d_checksum += $d_check[$i];
        }
 }

 But the result is different. I know that unpack in perl and php are
 different, but I cant find a way to translate the format %16n* of perl
 to php and generate a 16-bit checksum.

 Any help will be appreciated.

 []'s
 Gabriel.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PHP function unpack

2009-10-11 Thread Gabriel Hahmann
Hi,

I'm new to the list and I've search internet and didn't find an answer
to my problem.

I'm converting a perl script to PHP and I've done almost everything.
The only part of the code that I didn't get working on PHP was:

(PERL CODE)
foreach ($b_length,$b_mac,$b_crlf,$b_crlf,$a_body) {
$d_checksum += unpack(%16n*, $_);
}

The idea is to make a 16-bit checksum of all elements
($b_length,$b_mac,$b_crlf,$b_crlf,$a_body).

I'm tried translating the code to:

$arr_checksum = array($b_length,$b_mac,$b_crlf,$b_crlf,$File_Content);

$d_checksum = 0;
foreach($arr_checksum as $check_elem){
$d_check = unpack(n*, $check_elem);
for ($i=0;$i4;$i++){
$d_checksum += $d_check[$i];
}
}

But the result is different. I know that unpack in perl and php are
different, but I cant find a way to translate the format %16n* of perl
to php and generate a 16-bit checksum.

Any help will be appreciated.

[]'s
Gabriel.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php