What is the correct syntax for excluding subdirectories when reading files in PHP?

When reading files in PHP, you may want to exclude certain subdirectories from being included. To achieve this, you can use the `is_dir()` function to check if the current item being read is a directory, and then exclude it from the list of files. By adding a condition to skip directories, you can effectively exclude subdirectories when reading files.

$directory = "path/to/directory";
$files = array_diff(scandir($directory), array('..', '.'));

foreach ($files as $file) {
    $fullPath = $directory . '/' . $file;
    if (is_file($fullPath)) {
        // Process the file
    }
}