mercredi 9 janvier 2019

Extract a word from a file and check it in if statement

I got a word from a specific file :

$myFile = "archives/myfile.txt";
$text= file($myFile)[9];
echo $word; // gives 'tLabc23'

But when I make a statement to check if the word found corresponds to what I want...

   if ($word) == 'tLabc23'){
        echo 'ok';
    }
   else {
        echo 'ko';
   }

... that's very strange because I have a ko result

Is it because the word found is not well-formatted ? If yes how could I do to make that statement work ?

Thanks !

Aucun commentaire:

Enregistrer un commentaire