1. Go to this page and download the library: Download jc21/filelist library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jc21 / filelist example snippets
use jc21\FileList;
$fileList = new FileList;
$items = $fileList->get('/path/to/files');
// Use the items array
print '<pre>';
foreach ($items as $item) {
if ($item[FileList::KEY_TYPE] == FileList::TYPE_DIR) {
print 'd' . "\t" . $item[FileList::KEY_NAME] . PHP_EOL;
} else {
print 'f' . "\t" . $item[FileList::KEY_NAME] . "\t" . $item[FileList::KEY_SIZE] . "\t" . date('Y-m-d', $item[FileList::KEY_DATE]) . PHP_EOL;
}
}
print '</pre>';