What are some potential pitfalls of using PHP to search for files in a directory structure?

One potential pitfall of using PHP to search for files in a directory structure is that the search function may not be efficient if the directory contains a large number of files. To solve this issue, you can use PHP's built-in functions like `glob()` or `scandir()` to search for files in a directory.

$directory = "/path/to/directory";
$files = glob($directory . '/*');

foreach($files as $file) {
    echo $file . PHP_EOL;
}