What function in PHP can be used to retrieve the names of all files in a specific directory and store them in arrays?

To retrieve the names of all files in a specific directory and store them in arrays in PHP, you can use the `scandir()` function. This function returns an array of all files and directories in the specified directory. You can then filter out the directories from the array to get only the file names.

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

print_r($files);