What is the best way to rename multiple files in a folder using PHP?

When renaming multiple files in a folder using PHP, one approach is to loop through each file in the directory and use the `rename()` function to change the file name. This can be achieved by first opening the directory, iterating through each file, and using the `rename()` function to rename the file.

$dir = 'path/to/directory/';

if ($handle = opendir($dir)) {
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
            rename($dir . $file, $dir . 'new_' . $file);
        }
    }
    closedir($handle);
}