pack/unpack in PHP

Joe Stump joe at digg.com
Fri Oct 12 22:41:28 UTC 2007


I'm working on a PHP library for us to use here at Digg and was  
hoping someone could help me out with some of the basics. I can pack  
up and send a request over no problemo and I get a response, but  
unpacking with:

     $header = fread($fp, 12);
     $arr = unpack("a4NN", $header);

Doesn't quite work (PHP uses the same pack/unpack as Perl so I'm  
running off of that example). The response I get, according to bvi  
anyways, appears to be valid in that I get a null byte, RES, 0, 0, 0,  
17, 0, 0, 0, 10 (I'm sending 'helloworld', which is 10 bytes).

The $arr is:

Array
(
     [NN] => RES
)

Any ideas?

Thanks!

--Joe



More information about the Gearman mailing list