I have a folder store_files under that I have multiple sub-folders. Now I can get all folders and all the files. Now I want to get all folders and nothing else but zip files. I try to add condition that if file extension is equal to zip but seems not working. If I add the $ext == 'zip' nothing show in the output. Is there another way to get specific file like for example in images there's a glob($getDirectory. '*.zip')
function listFolderFiles($dir){
$ffs = scandir($dir);
echo '<ol>';
foreach($ffs as $ff){
$ext = pathinfo($ff, PATHINFO_EXTENSION);
if($ff != '.' && $ff != '..' && $ext == 'zip'){
echo '<li>';
$str = preg_replace('/\D/', '', $ff);
$str = substr($str, 0,-1);
$getYear = substr($str, 0,4);
$getMonth = substr($str, -4,2);
$getDay = substr($str, -2,2);
$theDate = $getYear.'-'.$getMonth.'-'.$getDay;
$theRealDate = date('Y M j', strtotime($theDate));
echo $theRealDate;
if(is_dir($dir.'/'.$ff)){
listFolderFiles($dir.'/'.$ff);
}
echo '</li>';
}
}
echo '</ol>';
}
listFolderFiles('store_files');