I'm current trying to use PHP's unpack feature to decode a binary string and
am running into a problem.

Here is the unpack command I am using

$playerdata = unpack("czero/A$lengthone/itwo/fthree/A*four", $rest);

basically it is setup so that the hash created has 5 key/value pairs named
zero, one, two, three and four.  However my problem is with the second
key/value pair.  Since the information I need for the second field is
dynamic I need to be able to set a variable there to tell PHP exactly how
many characters are to be parsed for that field.  So say $length = 5 right
now the command would be translated by PHP as

$playerdata = unpack("czero/A5one/itwo/fthree/A*four", $rest);

At least that's what I need =)  The problem I'm experiencing right now is
that PHP translates the variable as $lengthone instead of just $length which
of course always results in 0 and then causes the data to be parsed
incorrectly.  I cannot use whitespace to separate $length and one as then
the unpack feature breaks down thinking that whitespace should be in the
string I'm unpacking which messes things up as well.

Any suggestions/tips for handling this problem would be much appreciated =)
I've been plagued with this problem for a few days now and I'm having no
luck =/

Sincerely,

Craig Vincent


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to