dimanche 26 août 2018

PHP IS_DIR Condition Not Working In Loop With Continue

I know this is a dummy question.
But I have banging my head more than an hour to make it works.

$path = '/dir/path';
$files = scandir($path);
foreach ($files as $file) {
    if (($file === '.' || $file === '..') || (is_dir($file))) continue;
    if (empty($file)) {
        echo $file.'<br>';
    }
}

Suppose I just want to show empty files within a directory than also content subdirectories.

How to make the is_dir condition works with continue statement?

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire