function acceptable($list=NULL) {
		$accept=[];
		foreach (explode(',',str_replace(' ','',@$_SERVER['HTTP_ACCEPT']))
			as $mime)
			if (preg_match('/(.+?)(?:;q=([\d\.]+)|$)/',$mime,$parts))
				$accept[$parts[1]]=isset($parts[2])?$parts[2]:1;
		if (!$accept)
			$accept['*/*']=1;
		else {
			krsort($accept);
			arsort($accept);
		}
		if ($list) {
			if (is_string($list))
				$list=explode(',',$list);
			foreach ($accept as $mime=>$q)
				if ($q && $out=preg_grep('/'.
					str_replace('\*','.*',preg_quote($mime,'/')).'/',$list))
					return current($out);
			return FALSE;
		}
		return $accept;
	}
function acceptable($list=NULL) {
		$accept=[];
		foreach (explode(',',str_replace(' ','',@$_SERVER['HTTP_ACCEPT']))
			as $mime)
			if (preg_match('/(.+?)(?:;q=([\d\.]+)|$)/',$mime,$parts))
				$accept[$parts[1]]=isset($parts[2])?$parts[2]:1;
		if (!$accept)
			$accept['*/*']=1;
		else {
			krsort($accept);
			arsort($accept);
		}
		if ($list) {
			if (is_string($list))
				$list=explode(',',$list);
			foreach ($accept as $mime=>$q)
				if ($q && $out=preg_grep('/'.
					str_replace('\*','.*',preg_quote($mime,'/')).'/',$list))
					return current($out);
			return FALSE;
		}
		return $accept;
	}
function acceptable ( $ list = NULL ) { $ accept = [ ] ; foreach ( explode ( ',' , str_replace ( ' ' , '' , @ $ _SERVER [ 'HTTP_ACCEPT' ] ) ) as $ mime ) if ( preg_match ( '/(.+?)(?:;q=([\d\.]+)|$)/' , $ mime , $ parts ) ) $ accept [ $ parts [ 1 ] ] = isset ( $ parts [ 2 ] ) ? $ parts [ 2 ] : 1 ; if ( ! $ accept ) $ accept [ '*/*' ] = 1 ; else { krsort ( $ accept ) ; arsort ( $ accept ) ; } if ( $ list ) { if ( is_string ( $ list ) ) $ list = explode ( ',' , $ list ) ; foreach ( $ accept as $ mime => $ q ) if ( $ q && $ out = preg_grep ( '/' . str_replace ( '\*' , '.*' , preg_quote ( $ mime , '/' ) ) . '/' , $ list ) ) return current ( $ out ) ; return FALSE ; } return $ accept ; }
Return the MIME types stated in the HTTP Accept header as an array;
If a list of MIME types is specified, return the best match; or
FALSE if none found
@return array|string|FALSE
@param $list string|array
Return the MIME types stated in the HTTP Accept header as an array ; If a list of MIME types is specified return the best match ; or FALSE if none found