$dir = '/path/to/directory'; $files = scandir($dir); foreach($files as $file) { echo $file . '
'; }
$dir = '/path/to/directory'; $files = scandir($dir); foreach($files as $file) { if (is_file($dir . '/' . $file)) { echo $file . '
'; } }
$dir = '/path/to/directory'; $files = scandir($dir); foreach($files as $file) { if (is_dir($dir . '/' . $file)) { echo $file . 'This code will only list the directories within the specified directory. The Folder ls function is part of the PHP standard library, and does not require any additional libraries or packages.
'; } }