public static function generateQuickMatchFromList(array $strings)
	{
		foreach ($strings as $string)
		{
			$stringLen  = strlen($string);
			$substrings = [];

			for ($len = $stringLen; $len; --$len)
			{
				$pos = $stringLen - $len;

				do
				{
					$substrings[substr($string, $pos, $len)] = 1;
				}
				while (--$pos >= 0);
			}

			if (isset($goodStrings))
			{
				$goodStrings = array_intersect_key($goodStrings, $substrings);

				if (empty($goodStrings))
				{
					break;
				}
			}
			else
			{
				$goodStrings = $substrings;
			}
		}

		if (empty($goodStrings))
		{
			return false;
		}

		// The strings are stored by length descending, so we return the first in the list
		return strval(key($goodStrings));
	}
public static function generateQuickMatchFromList(array $strings)
	{
		foreach ($strings as $string)
		{
			$stringLen  = strlen($string);
			$substrings = [];

			for ($len = $stringLen; $len; --$len)
			{
				$pos = $stringLen - $len;

				do
				{
					$substrings[substr($string, $pos, $len)] = 1;
				}
				while (--$pos >= 0);
			}

			if (isset($goodStrings))
			{
				$goodStrings = array_intersect_key($goodStrings, $substrings);

				if (empty($goodStrings))
				{
					break;
				}
			}
			else
			{
				$goodStrings = $substrings;
			}
		}

		if (empty($goodStrings))
		{
			return false;
		}

		// The strings are stored by length descending, so we return the first in the list
		return strval(key($goodStrings));
	}
public static function generateQuickMatchFromList ( array $ strings ) { foreach ( $ strings as $ string ) { $ stringLen = strlen ( $ string ) ; $ substrings = [ ] ; for ( $ len = $ stringLen ; $ len ; -- $ len ) { $ pos = $ stringLen - $ len ; do { $ substrings [ substr ( $ string , $ pos , $ len ) ] = 1 ; } while ( -- $ pos >= 0 ) ; } if ( isset ( $ goodStrings ) ) { $ goodStrings = array_intersect_key ( $ goodStrings , $ substrings ) ; if ( empty ( $ goodStrings ) ) { break ; } } else { $ goodStrings = $ substrings ; } } if ( empty ( $ goodStrings ) ) { return false ; } // The strings are stored by length descending, so we return the first in the list return strval ( key ( $ goodStrings ) ) ; }
Generate a quickMatch string from a list of strings

This is basically a LCS implementation, tuned for small strings and fast failure

@param  array $strings Array of strings
@return mixed          quickMatch string, or FALSE if none could be generated
Generate a quickMatch string from a list of strings