1<?php
2 $folder = '/path/'; //directory or folder to loop through
3 $checkFiles = scandir($folder); //scan folder content
4 $fileCount = count($checkFiles); //count number of files in the directory
5 $i = 0; //set for iteration;
6 while($i < $fileCount){
7 $file = $checkFiles[$i]; //each file is stored in an array ...
8 if($file = '.' || $file = '..'){
9 //echo nothing
10 }else{
11 echo $file; // file names are printed out
12 }
13 }
14?>