liste unique de définition
This commit is contained in:
parent
bcfe6da555
commit
584f1a81a0
17
dico.php
17
dico.php
@ -12,15 +12,20 @@ if (($lecteur = fopen("dico.csv", "r")) !== FALSE) {
|
||||
while (($ligne = fgetcsv($lecteur, 0, "\t")) !== FALSE) {
|
||||
if (substr($ligne[0], 0, 1) != "#" && count($ligne) >= 3) {
|
||||
[$mot, $definition, $auteur] = $ligne;
|
||||
$mot = strtoupper($mot);
|
||||
if ($auteur) {
|
||||
$dico[strtoupper($mot)] = "$definition <small><em>$auteur</em></small>";
|
||||
} else {
|
||||
$dico[strtoupper($mot)] = $definition;
|
||||
$definition .= " <small><em>$auteur</em></small>";
|
||||
}
|
||||
$nb_espaces = substr_count($mot, ' ');
|
||||
if ($nb_espaces > 0) {
|
||||
$dico[$mot] .= " <small>(" . ($nb_espaces + 1) . " mots)</small>";
|
||||
$definition .= " <small>(" . ($nb_espaces + 1) . " mots)</small>";
|
||||
}
|
||||
if (strlen($definition)) {
|
||||
$dico[$mot] = [$definition];
|
||||
} else {
|
||||
$dico[$mot] = [];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
fclose($lecteur);
|
||||
@ -62,9 +67,9 @@ function mots_espaces($longueur)
|
||||
foreach ($mots_de_n_lettres[$i] as $mot1) {
|
||||
foreach (mots_espaces($longueur - $i - 1) as $mot2) {
|
||||
if ($mot1 != $mot2) {
|
||||
$dico["$mot1 $mot2"] = $dico[$mot1] && $dico[$mot2] ? "<li>{$dico[$mot1]}</li><li>{$dico[$mot2]}</li>" : $dico[$mot1] . $dico[$mot2];
|
||||
$dico["$mot1 $mot2"] = array_merge($dico[$mot1], $dico[$mot2]);
|
||||
yield "$mot1 $mot2";
|
||||
$dico["$mot2 $mot1"] = $dico[$mot2] && $dico[$mot1] ? "<li>{$dico[$mot2]}</li><li>{$dico[$mot1]}</li>" : $dico[$mot2] . $dico[$mot1];
|
||||
$dico["$mot2 $mot1"] = array_merge($dico[$mot2], $dico[$mot1]);
|
||||
yield "$mot2 $mot1";
|
||||
$nb_mots += 2;
|
||||
if ($nb_mots > MAX_MOTS) {
|
||||
|
26
index.php
26
index.php
@ -106,7 +106,18 @@ $grille = new Grille($hauteur, $largeur, $id);
|
||||
<h2>Horizontalement</h2>
|
||||
<ol>
|
||||
<?php for ($l = 0; $l < $hauteur; $l++): ?>
|
||||
<li><ol><?= $dico[$grille->get_ligne($l, $largeur)] ?></ol></li>
|
||||
<li>
|
||||
<?php $definitions = $dico[$grille->get_ligne($l, $largeur)] ?>
|
||||
<?php if (count($definitions) == 1): ?>
|
||||
<?= $definitions[0] ?>
|
||||
<?php else: ?>
|
||||
<ol>
|
||||
<?php foreach ($dico[$grille->get_ligne($l, $largeur)] as $definition) : ?>
|
||||
<li><?= $definition ?></li>
|
||||
<?php endforeach ?>
|
||||
</ol>
|
||||
<?php endif ?>
|
||||
</li>
|
||||
<?php endfor; ?>
|
||||
</ol>
|
||||
</div>
|
||||
@ -114,7 +125,18 @@ $grille = new Grille($hauteur, $largeur, $id);
|
||||
<h2>Verticalement</h2>
|
||||
<ol type="A">
|
||||
<?php for ($c = 0; $c < $largeur; $c++): ?>
|
||||
<li><ol><?= $dico[$grille->get_colonne($c, $hauteur)] ?></ol></li>
|
||||
<li>
|
||||
<?php $definitions = $dico[$grille->get_colonne($c, $hauteur)] ?>
|
||||
<?php if (count($definitions) == 1): ?>
|
||||
<?= $definitions[0] ?>
|
||||
<?php else: ?>
|
||||
<ol>
|
||||
<?php foreach ($dico[$grille->get_colonne($c, $hauteur)] as $definition) : ?>
|
||||
<li><?= $definition ?></li>
|
||||
<?php endforeach ?>
|
||||
</ol>
|
||||
<?php endif ?>
|
||||
</li>
|
||||
<?php endfor; ?>
|
||||
</ol>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user