toledorobia
1/5/2018 - 3:07 PM

PHP - Check dir is empty

PHP - Check dir is empty

<?php
function is_dir_empty($dir) {
    if (!is_readable($dir)) {
        return null;
    }
 
    return (count(scandir($dir)) == 2);
}
?>