I want to truncate a file with each loop and write again. So, I am using below code.
However, what is happening here is I am getting some extra space at the beginning in each loop. There is no space as 1st time no space is being added (also I tried trim function).
Can you please help me?
$file = fopen("progress/".$_POST['fname'].".txt","w");
while($row=mysql_fetch_assoc($result)){
updateDB($row['movieid'],trim($row['tempname']));
ftruncate($file,0);
fwrite($file,round(100*$complete++/$tot));
}
fclose($file);
OUTPUT: (something like this)
11
20
30
40