What function in PHP can be used to read the contents of a folder?

To read the contents of a folder in PHP, you can use the `scandir()` function. This function returns an array of files and directories in the specified folder. You can then iterate over this array to access each file or directory.

$folder = "path/to/folder";
$contents = scandir($folder);

foreach($contents as $item){
    echo $item . "<br>";
}