I'm trying to check if a folder is empty or not.
I use an Apache server and a Windows 10 operating system.
What's the problem with my code ?
function is_dir_empty($dir) {
if (!is_readable($dir)) return NULL;
return (count(scandir($dir)) == 2);
}
$dir = "C:/Users/name/.spyder/Python2/data/$day-$month-$year/emptyFolder";
print "<br>$dir<br>";
if (is_dir_empty($dir)) {
echo "the folder is empty";
}else{
echo "the folder is NOT empty";
}