How can the fread function in PHP be utilized to extract specific bytes from a file, such as the 5th and 7th byte for size information?

To extract specific bytes from a file using the `fread` function in PHP, you can open the file, seek to the desired position using `fseek`, and then read the specified number of bytes with `fread`. For example, to extract the 5th and 7th bytes from a file for size information, you would seek to position 4 (since indexing starts at 0) and read 2 bytes.

$file = fopen('example.txt', 'r');
if ($file) {
    fseek($file, 4); // seek to the 5th byte
    $sizeBytes = fread($file, 2); // read 2 bytes (5th and 6th)
    fclose($file);

    echo "Size information: " . bin2hex($sizeBytes); // convert bytes to hexadecimal for display
} else {
    echo "Unable to open file.";
}