I have a MySQL Blob that contains binary data. I have extracted this blob into a PHP variable using:
$line = mysql_fetch_next($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...?
Then I found "pack" from this thread, but I'm not sure if I can do this with pack... Anyone know of non-trivial examples using pack?