What are some best practices for displaying progress indicators when processing large CSV files in PHP?

When processing large CSV files in PHP, it's important to provide users with a progress indicator to show that the operation is ongoing. This can help prevent users from thinking the process has stalled or encountering timeouts. One way to implement this is by using a combination of PHP output buffering, flushing, and JavaScript to update a progress bar on the frontend.

```php
<?php

// Start output buffering
ob_start();

// Process the large CSV file
$csvFile = 'large_file.csv';
$handle = fopen($csvFile, 'r');
$totalRows = count(file($csvFile));
$currentRow = 0;

while (($data = fgetcsv($handle)) !== false) {
    // Process each row of the CSV file

    // Update progress
    $currentRow++;
    $progress = round(($currentRow / $totalRows) * 100, 2);
    
    // Output progress to the buffer
    echo "<script>updateProgressBar($progress);</script>";

    // Flush the buffer to output the progress to the browser
    ob_flush();
    flush();
}

// End output buffering
ob_end_flush();
?>
``` 

In the above code snippet, we start output buffering to capture the progress updates. As each row of the CSV file is processed, we calculate the progress percentage and output a JavaScript function call to update the progress bar on the frontend. The ob_flush() and flush() functions are used to send the progress updates to the browser in real-time.