title: Redirect only the first time and store the visitor's ip
body: <p>I have this code but when it enters ips.text, it only checks the first ip that is the number 0 and the others it leaves it does not verify them and I need help.</p>
  
  <pre><code>$ipArray = file('ips.txt');
      foreach ($ipArray as $ipTest) {
        if (substr_count($_SERVER['REMOTE_ADDR'],trim($ipTest)) != "0") { 
          die("HELLO IP LOCKED");
        } 
        else {
            header('Location: http://www.google.com/');
      };
        } 
      header('Content-Type: text/html; charset=UTF-8'); {
      $archivo="ips.txt"; $proceso=fopen($archivo,"a") or die ("error en el sistema"); 
      $ip= $_SERVER['REMOTE_ADDR']; $fecha= date("d/m/y"); 
      $datos="".$ip."\n";
       fwrite($proceso,$datos); 
      fclose($proceso); 
      }
  </code></pre>