While does not work for me. I have been checking for a long time and it all comes down to the fact that:

  1. There is a variable $ lig. Its value is derived from the fact that I count the number of cells in the $ nou array. It's all okay. (It should be 5, and it turns out)
  2. There is a $ f variable. It takes out of the loop. It does not work. For some reason, instead of those 5 times that it should work, only 2 work.

Question: I myself am a fool or something wrong with the program?

Not working excerpt:

$file = 'Data/Users/'.$_COOKIE['id'].'/chats.txt'; $f = fopen($file, 'r'); $arr = file($file); $nou = $arr; fclose($f); $lig = count($nou); $f = 0; $r = 0; while($f <= $lig){ $n = trim($nou[$f]); $file = 'Data/Messages/Chats/'.$n.'/user_in.txt'; $f = fopen($file, 'r'); $k = file($file); fclose($f); if($_GET['id'] === trim($k['0'])){ $r = 1; } else{ if($_GET['id'] === trim($k['1'])){ $r = 1; } } if($r === 1){ $i = $n; } $f++; } 

$ r after this is applied as follows: There is an if which creates a new chat, if $ r = 0, and if = 1, it skips.

  • one
    change the variable name for $f = fopen($file, 'r'); - splash58
  • @ Alexander Kornienko and why is the first $ f being created? - Kirill Korushkin

0