public function getPreferredResponseFormats($default = 'text/html')
    {
        // parse accept header (uses default instead of 406 header)
        $acpt = $this->getHeaderLine('Accept') ?: $default;
        $acpt = explode(',', $acpt);
        foreach ($acpt as $k => $v) {
            $v = array_pad(explode(';', $v, 2), 2, 'q=1');
            $v[1] = (float) array_pad(explode('q=', $v[1], 2), 2, '1')[1];
            $v[0] = $v[0];
            $v[2] = $k;
            $acpt[$k] = $v;
        }
        usort($acpt, function ($a, $b) {
            if ($a[1] > $b[1]) {
                return -1;
            }
            if ($a[1] < $b[1]) {
                return 1;
            }
            return $a[2] < $b[2] ? -1 : 1;
        });
        $acpt = array_map(function ($v) {
            return strtolower($v[0]);
        }, $acpt);
        $acpt = array_filter($acpt, function ($v) {
            return $v !== '*/*';
        });
        return array_unique($acpt);
    }
public function getPreferredResponseFormats($default = 'text/html')
    {
        // parse accept header (uses default instead of 406 header)
        $acpt = $this->getHeaderLine('Accept') ?: $default;
        $acpt = explode(',', $acpt);
        foreach ($acpt as $k => $v) {
            $v = array_pad(explode(';', $v, 2), 2, 'q=1');
            $v[1] = (float) array_pad(explode('q=', $v[1], 2), 2, '1')[1];
            $v[0] = $v[0];
            $v[2] = $k;
            $acpt[$k] = $v;
        }
        usort($acpt, function ($a, $b) {
            if ($a[1] > $b[1]) {
                return -1;
            }
            if ($a[1] < $b[1]) {
                return 1;
            }
            return $a[2] < $b[2] ? -1 : 1;
        });
        $acpt = array_map(function ($v) {
            return strtolower($v[0]);
        }, $acpt);
        $acpt = array_filter($acpt, function ($v) {
            return $v !== '*/*';
        });
        return array_unique($acpt);
    }
public function getPreferredResponseFormats ( $ default = 'text/html' ) { // parse accept header (uses default instead of 406 header) $ acpt = $ this -> getHeaderLine ( 'Accept' ) ? : $ default ; $ acpt = explode ( ',' , $ acpt ) ; foreach ( $ acpt as $ k => $ v ) { $ v = array_pad ( explode ( ';' , $ v , 2 ) , 2 , 'q=1' ) ; $ v [ 1 ] = ( float ) array_pad ( explode ( 'q=' , $ v [ 1 ] , 2 ) , 2 , '1' ) [ 1 ] ; $ v [ 0 ] = $ v [ 0 ] ; $ v [ 2 ] = $ k ; $ acpt [ $ k ] = $ v ; } usort ( $ acpt , function ( $ a , $ b ) { if ( $ a [ 1 ] > $ b [ 1 ] ) { return - 1 ; } if ( $ a [ 1 ] < $ b [ 1 ] ) { return 1 ; } return $ a [ 2 ] < $ b [ 2 ] ? - 1 : 1 ; } ) ; $ acpt = array_map ( function ( $ v ) { return strtolower ( $ v [ 0 ] ) ; } , $ acpt ) ; $ acpt = array_filter ( $ acpt , function ( $ v ) { return $ v !== '*/*' ; } ) ; return array_unique ( $ acpt ) ; }
Get the prefered response formats.
@param  string                    $default the default value to return if the Accept header is not present.
@return string[]                  the desired response formats
Get the prefered response formats .