How can the glob() function be used to read file names in PHP?
The glob() function in PHP can be used to read file names by matching a specific pattern. This function allows you to retrieve an array of file names that match the specified pattern, making it easy to iterate over and work with multiple files in a directory.
// Get an array of file names in a directory
$files = glob('path/to/directory/*.txt');
// Iterate over the array of file names
foreach ($files as $file) {
echo $file . "<br>";
}