Gist

Örnek

// folder path and
// limits of selected files, *.* = all files
$folder = 'upload/profiles/2018-11/*.*';

// searched extensions
$ext_array = ['gif','jpg','jpeg','png'];

// get all files
$files = glob($folder);

// if there is any file
if ($files && is_array($files)){
// loop in $files
foreach ($files as $file){
// get file ext
$file_ext = pathinfo($file, PATHINFO_EXTENSION);

// if tehre is valid ext and searhed ext
if ($file_ext && in_array($file_ext, $ext_array)){
echo "";
}
}
} else {
echo 'there is no file';
}