I have a directory named client_images that has dir_1, dir_2 and dir_3 as subdirectories. When i run the following:
foreach(scandir("client_images") as $key => $value ){
if(is_dir($value)){
echo $value." is a dir.<br>";
}
else{
echo $value." is not a dir.<br>";
}
}
i get :
. is a dir. .. is a dir. dir_1 is not a dir. dir_2 is not a dir. dir_3 is not a dir.
Why is php returning false for directories?
You are doing
scandir("client_images"); the result is bare filenames without theclient_images/path, so it’s looking for them in the current directory. Naturally, the only directories likely to be in common between.. andclient_images/are.and.., the entries present in all directories.