title: Multiple file checking with php and create the file if does not exist
body: <p>I have a php script that checks if any of the 5 files exist
  file1, file2, file3, file4, file5 in sequential order</p>
  
  <p>if file1 exist then check for file2
  if file2 exist then check for file3
  if file3 exist then check for file4
  if file4 exist then check for file5</p>
  
  <p>if any of the files dont exist then create that file and if all files exist then sleep for few seconds until 1 of the files get deleted and then create that file before executing the code</p>
  
  <p>i have my logic clear but i am not able to put the code into action</p>
  
  <p>below is my code</p>
  
  <pre><code>while(file_exists("/var/tmp/test/" . $tempfile) &amp;&amp; file_exists("/var/tmp/test/" . $tempfile2) &amp;&amp; file_exists("/var/tmp/test/" . $tempfile3) &amp;&amp; file_exists("/var/tmp/test/" . $tempfile4) &amp;&amp; file_exists("/var/tmp/test/" . $tempfile5))
  {
      sleep (3);
  }
  
  if file 1 exist
  {
      if file 2
      {
          if file 3
          {
              if file 4
              {   
                  create file 5
              }
              else
              {
                  create file 4
              }
          }
          else
          {
              create file 1
          }
      }
      else
      {
          create file 1
      }
  }
  else
  {
      create file 1
  }
  </code></pre>
  
  <p>is there a better way of writing it ?</p>