What potential issues can arise when handling Range requests in PHP?

Issue: One potential issue when handling Range requests in PHP is that the server may not correctly parse the Range header provided by the client, leading to incorrect or unexpected behavior. To solve this, we can use the `http_parse_headers` function to properly parse the Range header and extract the requested range values.

// Function to parse Range header
function parseRangeHeader($header) {
    $matches = [];
    preg_match('/bytes=(\d+)-(\d+)?/', $header, $matches);
    
    if (count($matches) === 3) {
        return [
            'start' => intval($matches[1]),
            'end' => intval($matches[2])
        ];
    } else {
        return null;
    }
}

// Example usage
$headers = getallheaders();
if (isset($headers['Range'])) {
    $range = parseRangeHeader($headers['Range']);
    if ($range) {
        $start = $range['start'];
        $end = $range['end'];
        // Process range request accordingly
    }
}