I need to use php to read binary files that begin something like this:
00000000: 06 00 00 00 43 5f 54 4b 84 05 00 00 2c 00 00 00
00000010: 73 65 63 20 18 00 00 00 02 00 00 00 00 00 c0 40
00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 c1
The first 4 bytes are a long number. I can't figure out how to fread
longs into an integer in php. Basically I need a function like:
$n = read_int($fp, $offset);
And the same thing for floats, doubles, shorts, unsigned shorts, etc.
How do you do this in php? I know that the file need to be opened in
binary mode, but fread just returns a string.
Comment