title: filesize() return 0 ?
body: <p>im trying to insert an array values into the file using foreach.. and if the file size became up to 1MB (1000000byte). the script create a new file and put the value inside...</p>
  
  <p>this is the code what i used :</p>
  
  <pre class="lang-php prettyprint-override"><code>foreach($array as $code){  
  
  if(filesize($file_name) &lt; '1000000'){
      $update_file = file_get_contents($file_name);
      file_put_contents($file_name,$update_file.$code);
  }else{
      $open = fopen($file_name.rand('99999'),'w');
      file_put_contents($file_name,$code);
  
      }
  echo filesize($file_name);
  }
  </code></pre>
  
  <p>now the problem is the function "filesize()" is always returning 0,, but if i remove the code above it and put <code>echo filesize($file_name);</code> only in the page .. it return the right value (size of file), the script also make only 1 file even it became more than 1MB because the filesize is 0 as filesize() function return !.</p>
  
  <p>i checked this question <a href="https://stackoverflow.com/questions/5167313/php-problem-filesize-return-0-with-file-containing-few-data">PHP Problem : filesize() return 0 with file containing few data?</a>
  but it still not working even i follow the answer #1</p>
  
  <p>i wish that you understand my problem.. and im sorry for my english.</p>