Hi, I'm new here - I just posted to an older thread with a question, hoping it would "bump" the thread to the top, but it didn't appear to... So I'll post my question in its own thread -- I hope I didn't break any rules:
I have a MySQL Blob that contains binary data. I have extracted this blob into a PHP variable using:
$line = mysql_fetch_array($query, MYSQL_ASSOC);
Now, $line is an array of columns, with the variable:
$line['binary_column'] referencing my binary data.
The format of the binary data is:
[Double] : Average A,
[Double] : Average B,
[Double] : Average C,
[Unsigned Int] : Count A Pairs to Follow,
[char] : x1,
[char] : y1,
[char] : v1,
[char] : ...
[char] : xN,
[char] : yN,
[char] : vN,
[Unsigned Int] : Count B Pairs to Follow,
[char] : x1,
[char] : y1,
[char] : v1,
[char] : ...
[char] : xN,
[char] : yN,
[char] : vN,
[Unsigned Int] : Count C Pairs to Follow,
[char] : x1,
[char] : y1,
[char] : v1,
[char] : ...
[char] : xN,
[char] : yN,
[char] : vN
I want to construct PHP variables out of the binary blob data -- construct 'php variables' from the three initial doubles, extract the chars-to-follow, and then build up array of the coefficient elements (each char in the binary stream is a coefficient).
any clue on how to do this? I was looking into the fread functions, but I don't know how to map a file handle over the php object representing the blob...?
After searching this board, I found "unpack", but I couldn't find any non-trivial examples of its use -- could it help me decode this binary data? Specifically, can I somehow give "unpack" an offset into the object returned in the object at $line['binary_column']?