<?php $files = scandir('img/back'); $files = array_splice($files, 2); sort($files); // this does the sorting foreach ($files as $file) { echo ''; } code example
Example 1: php get all php files in a directory
foreach(glob('includes/*.php') as $file) {
...
}
Example 2: php list directories
$dir = '.';
$directories = glob($dir . '/*', GLOB_ONLYDIR);