What is the purpose of using the "flush" function in PHP?

The "flush" function in PHP is used to send the output buffer to the browser immediately, instead of waiting for the script to finish executing. This can be useful when you want to show progress to the user during a long-running script or when you want to stream data to the browser in real-time.

// Send output buffer to the browser immediately
flush();