18
In PHP, if you have a variable with binary data, how do you get specific bytes from the data? For example, if I have some data that is 30 bytes long how do I get the first 8 bytes?
Right now, I'm treating it like a string, using the substr() function:
$data = //...
$first8Bytes = substr($data, 0, 8);
Is it safe to use substr with binary data?
Or are there other functions that I should be using?