This may be posted elsewhere, but I haven't seen it.
To run a progress indicator while the program is running without outputting the output buffer, the following will work:
echo "<p>Search running. Please be patient. . .";
$output = "<p>FileList: </p>\n";
if (is_dir($dir)) {
$dh = opendir($dir);
while (($fd = readdir($dh)) != false) {
echo " .";
ob_start();
echo $fd;
$output .= ob_get_contents();
ob_end_clean();
}
}
echo "</br>Search Complete!</p>\n";
echo $output;
The program will continue to print the " ." without printing the file list. Then the "Search Complete" message will print followed by the buffered file list.
ob_clean