title: how to stop duplicate values from being written to text file using php
body: <p>i have a script that keeps reloading every 2 seconds, i made a code to create a txt file for each user IP and write the user name <code>$name</code> inside it. my problem is that everytime my script reloads it will write the <code>$name</code> of the specific IP again with every reload.
  the code is</p>
  
  <pre><code> $ip_file = "ips/".$ip.".txt";
  
      $logip = fopen($ip_file,"a", 1);
  
      $name = $name."\n";
  
      fwrite($logip, $name);  
  
      fclose($logip);
  
      return;
  </code></pre>
  
  <p>i need some way to verify if the name is already in the <code>$ip_file</code> and if it's there then not to write it again.</p>
  
  <p>the idea behind this is to check if the same IP is used by more than one <code>$name</code> and then create a function to check all the <code>$ip_file</code> files for more than 1 <code>$name</code> and if so ban the violating <code>$ip</code></p>
  
  <p>thanks in advance</p>