How to check this file? [closed]

0
<?php 

$ponteiro = fopen("nome.txt","r");

//LÊ O ARQUIVO ATÉ 
while (!feof ($ponteiro)) {
  //LÊ UMA
  $linha = fgets($ponteiro, 4096);
  echo "<b>".$linha."<br>";
}//FECHA WHILE

//FECHA
fclose ($ponteiro);
?>

I wanted to know if there is any way to do a check in the txt file if there is a "1" or "dast" name and play in the database

    
asked by anonymous 08.03.2018 / 21:53

1 answer

1

See if that's it:

<?php
$termo = "dast";
$ponteiro = fopen("nome.txt", "r");
$linha = fgets($ponteiro, 4096);
if(strpos($linha,$termo) !== false){
    echo "Econtrado";
}else{
    echo "Não existe";
}
fclose ($ponteiro);
?>

But if you want to do a DB with files I advise you to learn JSON, the search would be more precise.

    
09.03.2018 / 02:05