Comparer un mot avec un dossier file

Résolu
jun_1393 Messages postés 32 Statut Membre -  
jun_1393 Messages postés 32 Statut Membre -
Bonjour,
je travaille sur un code de vigenere depuis un moment et je voudrais faire une fonction qui verifie si le mot entré est bien un mot français , ce mot sera comapré avec different mot qui sont dans un file (dictionnaire )
merci de votre aide.
ceux que j'Ai essayer mais sa marche pas
interface ICryptographie
{
    public function encoder($key, $text);

    public function decoder($key, $text);

    public function regexp($chaine);

    function valider($file_mondic, $text);

    function randomkey();




}

class Crypto implements ICryptographie
{


    function valider($file_mondic, $text){
        $file_mondic = file(__DIR__ . "/Clef/mondic.txt", FILE_IGNORE_NEW_LINES);
        $valid = true;
        foreach ($file_mondic as $text){
            if(strlen($file_mondic == $text) ) { //if string matches
                return $text; //return string if matched
            }else {
                echo "<script>alert(\"le mot ou texte n'Est pas français\")</script>";
            }
        }

1 réponse

  1. jun_1393 Messages postés 32 Statut Membre
     
    toujours la même problématique j'ai essaye d'ajouter une regex pour géré les accents de certain charactere

    interface ICryptographie
    {
    public function encoder($key, $text);

    public function decoder($key, $text);

    public function regexp($chaine);

    function valider($file_mondic, $text);

    function randomkey();

    }

    class Crypto implements ICryptographie
    {

    function valider($file_mondic, $text){
    $file_mondic = file(__DIR__ . "/Clef/mondic.txt", FILE_IGNORE_NEW_LINES);
    $valid = true;
    foreach ($file_mondic as $text){

    $text = strlower($text)
    $text = preg_replace("/([jlmtcnds]{1}{'}?\W?/"
    if(strlen($file_mondic == $text) ) { //if string matches
    return $text; //return string if matched
    }else {
    echo "<script>alert(\"le mot ou texte n'Est pas français\")</script>";
    }
    }
    0