是否可以检查具有相同文件名的文件(仅文件扩展名不同)并且只显示它们的名称一次?
if (is_dir($dir_path)) {
$files = scandir($dir_path);
foreach($files as $file) {
if ( !in_array( $file, $exclude_all ) ) {
$path_to_file = $dir_path . $file;
$bare_name = pathinfo( $path_to_file, PATHINFO_FILENAME );
$extension = pathinfo( $path_to_file, PATHINFO_EXTENSION );
echo 'Path to file: ' . $path_to_file . '<br />';
echo 'Bare file name: ' . $bare_name . '<br />';
echo 'Extension: ' . $extension . '<br />';
}
}
}