src/Net/HTTP/Header/Field/Parser.php
static public function decodeQualifiedValues( $qualifiedValues, $sortByLength = FALSE ){
		$pattern	= '/^(\S+)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/iU';
		$parts		= preg_split( '/,\s*/', $qualifiedValues );
		$codes		= array();
		foreach( $parts as $part )
			if( preg_match ( $pattern, $part, $matches ) )
				$codes[$matches[1]]	= isset( $matches[2] ) ? (float) $matches[2] : 1.0;
		$map	= array();
		foreach( $codes as $code => $quality ){
			if( !isset( $map[(string)$quality] ) )
				$map[(string)$quality]	= array();
			$map[(string)$quality][strlen( $code)]	= $code;
			if( $sortByLength )
				krsort( $map[(string)$quality] );													//  sort inner list by code length
		}
		krsort( $map );																				//  sort outer list by quality
		$list	= array();
		foreach( $map as $quality => $codes )														//  reduce map to list
			foreach( $codes as $code )
				$list[$code]	= (float) $quality;
		return $list;
	}
static public function decodeQualifiedValues( $qualifiedValues, $sortByLength = FALSE ){
		$pattern	= '/^(\S+)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/iU';
		$parts		= preg_split( '/,\s*/', $qualifiedValues );
		$codes		= array();
		foreach( $parts as $part )
			if( preg_match ( $pattern, $part, $matches ) )
				$codes[$matches[1]]	= isset( $matches[2] ) ? (float) $matches[2] : 1.0;
		$map	= array();
		foreach( $codes as $code => $quality ){
			if( !isset( $map[(string)$quality] ) )
				$map[(string)$quality]	= array();
			$map[(string)$quality][strlen( $code)]	= $code;
			if( $sortByLength )
				krsort( $map[(string)$quality] );													//  sort inner list by code length
		}
		krsort( $map );																				//  sort outer list by quality
		$list	= array();
		foreach( $map as $quality => $codes )														//  reduce map to list
			foreach( $codes as $code )
				$list[$code]	= (float) $quality;
		return $list;
	}
static public function decodeQualifiedValues ( $ qualifiedValues , $ sortByLength = FALSE ) { $ pattern = '/^(\S+)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/iU' ; $ parts = preg_split ( '/,\s*/' , $ qualifiedValues ) ; $ codes = array ( ) ; foreach ( $ parts as $ part ) if ( preg_match ( $ pattern , $ part , $ matches ) ) $ codes [ $ matches [ 1 ] ] = isset ( $ matches [ 2 ] ) ? ( float ) $ matches [ 2 ] : 1.0 ; $ map = array ( ) ; foreach ( $ codes as $ code => $ quality ) { if ( ! isset ( $ map [ ( string ) $ quality ] ) ) $ map [ ( string ) $ quality ] = array ( ) ; $ map [ ( string ) $ quality ] [ strlen ( $ code ) ] = $ code ; if ( $ sortByLength ) krsort ( $ map [ ( string ) $ quality ] ) ; //  sort inner list by code length } krsort ( $ map ) ; //  sort outer list by quality $ list = array ( ) ; foreach ( $ map as $ quality => $ codes ) //  reduce map to list foreach ( $ codes as $ code ) $ list [ $ code ] = ( float ) $ quality ; return $ list ; }
Tries to decode qualified values into a map of values ordered by their quality.

@static
@access		public
@param		string		$string			String of qualified values to decode
@param		boolean		$sortByLength	Flag: assume longer key as more qualified for keys with same quality (default: FALSE)
@return		array		Map of qualified values ordered by quality
Tries to decode qualified values into a map of values ordered by their quality .