if (ob_get_level() == 0) ob_start();
foreach($posts as $post) {
ob_flush();
flush();
(...... custom code here )
ob_flush();
flush();
}
printf("<br/>All tasks finished<br/>");
ob_end_flush();
exit;
Keep scroll to bottom of body
<script>
setInterval(function () {window.scrollTo(0, document.body.scrollHeight);}, 1000);
</script>