I have to extract some data from a binary file. the data begin with a hex marker.
I have first to find this marker and then extract the x bytes after.
PHP is good for text file manipulation.
Someone have a good idea to do that with binary data ?
Thanks !
You don’t need any special functions like pack or unpack etc…although pack may be useful for specifying the needle to search for.
php doesn’t apply any character encoding to strings, it leaves them as is, so it’s binary friendly by default.
you may consider using fopen and fread in an iterative fashion if the size of the file is large, as file_get_contents would consume a lot of memory in that case. But that’s a separate question anyway.