changement de format du dictionnaire
This commit is contained in:
parent
ffe308ba3e
commit
2e93e2c878
26
dico.php
26
dico.php
@ -22,18 +22,14 @@ function dico($longueur_max) {
|
|||||||
|| strlen($ligne[0]) > $longueur_max
|
|| strlen($ligne[0]) > $longueur_max
|
||||||
) continue;
|
) continue;
|
||||||
|
|
||||||
switch(count($ligne)) {
|
$mot = $ligne[0];
|
||||||
case 1:
|
$definitions = array_slice($ligne, 1);
|
||||||
[$mot] = $ligne;
|
|
||||||
$definition = "";
|
foreach ($definitions as $i => $definition) {
|
||||||
break;
|
if (strpos($definition, "@") !== false) {
|
||||||
case 2:
|
[$definition, $auteur] = explode("@", $definition);
|
||||||
[$mot, $definition] = $ligne;
|
$definitions[$i] = "$definition <small><em>$auteur</em></small>";
|
||||||
break;
|
}
|
||||||
case 3:
|
|
||||||
[$mot, $definition, $auteur] = $ligne;
|
|
||||||
$definition .= " <small><em>$auteur</em></small>";
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$mot = str_replace("-", " ", $mot);
|
$mot = str_replace("-", " ", $mot);
|
||||||
@ -42,12 +38,10 @@ function dico($longueur_max) {
|
|||||||
$mots = explode(" ", $mot);
|
$mots = explode(" ", $mot);
|
||||||
$nb_mots = count($mots);
|
$nb_mots = count($mots);
|
||||||
$mot = implode("", $mots);
|
$mot = implode("", $mots);
|
||||||
$definition .= " ($nb_mots mots)";
|
$definition .= " <small>($nb_mots mots)</small>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$longueur = strlen($mot);
|
$dico[strlen($mot)][$mot] = $definitions;
|
||||||
if (!isset($dico[$longueur][$mot])) $dico[$longueur][$mot] = [];
|
|
||||||
if (strlen($definition)) $dico[$longueur][$mot][] = $definition;
|
|
||||||
}
|
}
|
||||||
fclose($lecteur);
|
fclose($lecteur);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user