$longueur_max ) continue; $mot = $ligne[0]; $definition = array_slice($ligne, 1); $mot = str_replace("-", CASE_NOIRE, $mot); $mot = $transliterator->transliterate($mot); if (strpos($mot, CASE_NOIRE) !== false) { $mots = explode(CASE_NOIRE, $mot); $nb_mots = count($mots); $mot = implode("", $mots); } else { $nb_mots = 1; } if (array_key_exists($mot, $dico)) { $dico[strlen($mot)][$mot][] = $definition; } else { $dico[strlen($mot)][$mot] = [$definition]; if ($nb_mots > 1) $dico[strlen($mot)][$mot]["nb_mots"] = $nb_mots; } } fclose($lecteur); } return $dico; } function mots_espaces($longueur_max) { $longueur_min = 1; $dico = dico($longueur_max); for ($longueur = 3; $longueur <= $longueur_max; $longueur++) { //$longueur_min = $longueur == $longueur_max ? 1 : 2; for ($position_espace = $longueur - 2; $position_espace >= $longueur_min; $position_espace--) { $mots_suivants = $dico[$longueur - $position_espace - 1]; foreach ($dico[$position_espace] as $premier_mot => $definition) { $premier_mot[] = CASE_NOIRE; $dico[$longueur][$premier_mot] = $mots_suivants; } } } return $dico; }