How can PHP be used to display the contents of a local file system on a website?

To display the contents of a local file system on a website using PHP, you can use the `scandir()` function to get a list of files and directories in a specified directory. You can then loop through the array of files and directories and display them on the webpage.

<?php
$dir = '/path/to/directory/';

// Check if the directory exists
if(is_dir($dir)){
    // Get list of files and directories
    $files = scandir($dir);

    // Loop through the array and display each file or directory
    foreach($files as $file){
        echo $file . "<br>";
    }
} else {
    echo "Directory not found";
}
?>