What function can be used in PHP to retrieve all files in a folder and store them in an array?

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

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

print_r($files);