From 02f17f78bfb626496d48eff6a731e0fdcd6307d2 Mon Sep 17 00:00:00 2001 From: adrien Date: Sat, 10 Jan 2026 21:53:14 +0100 Subject: [PATCH] ruc --- Grille.php | 21 ++++++++++++++++----- dico.php | 11 +---------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Grille.php b/Grille.php index da7ffdb..c48c097 100644 --- a/Grille.php +++ b/Grille.php @@ -104,11 +104,16 @@ class Grille implements ArrayAccess $this->definitions["horizontales"][$y] = []; foreach($mots as $mot) { $definitions = $this->dico[$mot["longueur"]][$mot["mot"]]; - var_dump($definitions); if (count($definitions)) { $definition = $definitions[mt_rand(0, count($definitions) - 1)]; - if (isset($definition["definition"])) $mot["definition"] = $definition["definition"]; - if (isset($definition["auteur"])) $mot["auteur"] = $definition["auteur"]; + if (is_array($definition)) { + foreach ($definition as $auteur => $def) { + $mot["definition"] = $def; + $mot["auteur"] = $auteur; + } + } else if (is_string($definition)) { + $mot["definition"] = $definition; + } } if (isset($definitions["nb_mots"])) { $mot["nb_mots"] = $definitions["nb_mots"]; @@ -124,8 +129,14 @@ class Grille implements ArrayAccess $definitions = $this->dico[$mot["longueur"]][$mot["mot"]]; if (count($definitions)) { $definition = $definitions[mt_rand(0, count($definitions) - 1)]; - if (isset($definition["definition"])) $mot["definition"] = $definition["definition"]; - if (isset($definition["auteur"])) $mot["auteur"] = $definition["auteur"]; + if (is_array($definition)) { + foreach ($definition as $auteur => $def) { + $mot["definition"] = $def; + $mot["auteur"] = $auteur; + } + } else if (is_string($definition)) { + $mot["definition"] = $definition; + } } if (isset($definitions["nb_mots"])) { $mot["nb_mots"] = $definitions["nb_mots"]; diff --git a/dico.php b/dico.php index 90a06e7..fb9dfdd 100644 --- a/dico.php +++ b/dico.php @@ -30,17 +30,8 @@ function dico($longueur_max) { if (strlen($mot) > $longueur_max) continue; - $dico[strlen($mot)][$mot] = []; + $dico[strlen($mot)][$mot] = $definitions; if ($nb_mots > 1) $dico[strlen($mot)][$mot]["nb_mots"] = $nb_mots; - foreach ($definitions as $definition) { - if (is_array($definition)) { - foreach ($definition as $auteur => $def) { - $dico[strlen($mot)][$mot][] = ["auteur" => $auteur, "definition" => $def]; - } - } else if (is_string($definition)) { - $dico[strlen($mot)][$mot][] = ["definition" => $definition]; - } - } } return $dico;