Skip to content

Instantly share code, notes, and snippets.

@asilbalaban
Created February 23, 2022 08:44
Show Gist options
  • Save asilbalaban/d3d4f18012d3c728ddc4e21f44fe64d2 to your computer and use it in GitHub Desktop.
Save asilbalaban/d3d4f18012d3c728ddc4e21f44fe64d2 to your computer and use it in GitHub Desktop.
obflush foreach in php
<?php
$array = ['a', 'b', 'c'];
if (ob_get_level() == 0) ob_start();
foreach ($array as $key => $val) {
echo $key . ' - ' . $val . '<br>';
ob_flush();
flush();
echo '<script>var scrollingElement = (document.scrollingElement || document.body);
scrollingElement.scrollTop = scrollingElement.scrollHeight;</script>';
}
ob_end_flush();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment