'a', 'à' => 'a', 'â' => 'a', 'ä' => 'a', 'ã' => 'a', 'å' => 'a', 'ą' => 'a', 'ă' => 'a', 'ç' => 'c', 'ć' => 'c', 'č' => 'c', 'é' => 'e', 'è' => 'e', 'ê' => 'e', 'ë' => 'e', 'ę' => 'e', 'í' => 'i', 'ì' => 'i', 'î' => 'i', 'ï' => 'i', 'ł' => 'l', 'ñ' => 'n', 'ń' => 'n', 'ó' => 'o', 'ò' => 'o', 'ô' => 'o', 'ö' => 'o', 'õ' => 'o', 'ø' => 'o', 'ő' => 'o', 'ř' => 'r', 'ś' => 's', 'š' => 's', 'ș' => 's', 'ş' => 's', 'ț' => 't', 'ţ' => 't', 'ú' => 'u', 'ù' => 'u', 'û' => 'u', 'ü' => 'u', 'ű' => 'u', 'ý' => 'y', 'ÿ' => 'y', 'ź' => 'z', 'ż' => 'z', 'ž' => 'z', 'ß' => 'ss', ); /** * Comparable key of a text: "Dark Blue", "dark-blue" and "DARK BLUE!" all give "dark blue". * * @param string $text Text (percent-encoded text is decoded first). */ public static function key( string $text ): string { $text = rawurldecode( $text ); $text = function_exists( 'mb_strtolower' ) ? mb_strtolower( $text, 'UTF-8' ) : strtolower( $text ); $text = strtr( $text, self::ACCENTS ); $text = (string) preg_replace( '/[^\p{L}\p{N}]+/u', ' ', $text ); return trim( $text ); } /** * The words of a text key. * * @param string $text Text. * @return string[] */ public static function words( string $text ): array { $key = self::key( $text ); return '' === $key ? array() : explode( ' ', $key ); } }