private static function parseRaw(string $input, array &$data = [])
    {
        preg_match('/boundary=(.*)$/', $_SERVER['CONTENT_TYPE'], $matches);

        $blocks = preg_split('/-+' . ($matches[1] ?? '') . '/', $input);

        array_pop($blocks);

        foreach ($blocks as $id => $block) {
            if (empty($block)) {
                continue;
            }
            if (strpos($block, 'application/octet-stream') !== false) {
                preg_match("/name=\"([^\"]*)\".*stream[\n|\r]+([^\n\r].*)?$/s", $block, $matches);
            } else {
                preg_match('/name=\"([^\"]*)\"[\n|\r]+([^\n\r].*)?\r$/s', $block, $matches);
            }
            $data[$matches[1]] = $matches[2];
        }
    }
private static function parseRaw(string $input, array &$data = [])
    {
        preg_match('/boundary=(.*)$/', $_SERVER['CONTENT_TYPE'], $matches);

        $blocks = preg_split('/-+' . ($matches[1] ?? '') . '/', $input);

        array_pop($blocks);

        foreach ($blocks as $id => $block) {
            if (empty($block)) {
                continue;
            }
            if (strpos($block, 'application/octet-stream') !== false) {
                preg_match("/name=\"([^\"]*)\".*stream[\n|\r]+([^\n\r].*)?$/s", $block, $matches);
            } else {
                preg_match('/name=\"([^\"]*)\"[\n|\r]+([^\n\r].*)?\r$/s', $block, $matches);
            }
            $data[$matches[1]] = $matches[2];
        }
    }
private static function parseRaw ( string $ input , array & $ data = [ ] ) { preg_match ( '/boundary=(.*)$/' , $ _SERVER [ 'CONTENT_TYPE' ] , $ matches ) ; $ blocks = preg_split ( '/-+' . ( $ matches [ 1 ] ?? '' ) . '/' , $ input ) ; array_pop ( $ blocks ) ; foreach ( $ blocks as $ id => $ block ) { if ( empty ( $ block ) ) { continue ; } if ( strpos ( $ block , 'application/octet-stream' ) !== false ) { preg_match ( "/name=\"([^\"]*)\".*stream[\n|\r]+([^\n\r].*)?$/s" , $ block , $ matches ) ; } else { preg_match ( '/name=\"([^\"]*)\"[\n|\r]+([^\n\r].*)?\r$/s' , $ block , $ matches ) ; } $ data [ $ matches [ 1 ] ] = $ matches [ 2 ] ; } }
Parse raw http request to array.

Based on parse_raw_http_request function of @Christof.

@link https://stackoverflow.com/a/5488449

@since 2.0.0
Parse raw http request to array .