What are best practices for efficiently processing files in a directory using PHP?

When processing files in a directory using PHP, it is important to efficiently loop through the files and perform the necessary operations without causing performance issues. One way to achieve this is by using the `glob()` function to retrieve an array of file paths in the directory, and then iterating over this array to process each file individually.

$files = glob('/path/to/directory/*');
foreach ($files as $file) {
    // Process each file here
    // Example: echo basename($file) . PHP_EOL;
}