How can PHP be used to create a file system that displays files and directories?

To create a file system in PHP that displays files and directories, you can use functions like `scandir()` to get a list of files and directories in a specified directory. You can then iterate through the list and display each item accordingly, distinguishing between files and directories.

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

$files = scandir($dir);

foreach($files as $file){
    if(is_file($dir . '/' . $file)){
        echo "File: $file<br>";
    } elseif(is_dir($dir . '/' . $file)){
        echo "Directory: $file<br>";
    }
}
?>