I am caputuring the contents for a file with ob_start() the contents are generated through a loop and within that loop I have another ob_start() outputting to a second file.
Like this
ob_start()
for(loop=0;$loop<=1000;$loop++){
ob_start();
?>
<p style="text-align:center"><?php echo $studentCounter.'/'.count($students);?></p>
<?php
file_put_contents('htmlpolling/'.$datePassed.$_SESSION['userCode'].'TTT'.$studentCounter.'.html', ob_get_clean());
}
file_put_contents('htmlpolling/'.$_SESSION['userCode'].'.html', ob_get_clean());
The files create successfully, but the files which are created inside the loop don't appear until the loop as finished and the final file is written.
Any reason for this?
Issue was that there was a lot of retrieving from databases / storing in arrays before the file creation happened... once all of that time consuming bit was done, files were actually creating pretty much immediately which is why they APPEARED to only generate at the end.