Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
16
Task/Empty-directory/PHP/empty-directory.php
Normal file
16
Task/Empty-directory/PHP/empty-directory.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
$dir = 'path_here';
|
||||
|
||||
if(is_dir($dir)){
|
||||
//scandir grabs the contents of a directory and array_diff is being used to filter out .. and .
|
||||
$list = array_diff(scandir($dir), array('..', '.'));
|
||||
//now we can just use empty to check if the variable has any contents regardless of it's type
|
||||
if(empty($list)){
|
||||
echo 'dir is empty';
|
||||
}
|
||||
else{
|
||||
echo 'dir is not empty';
|
||||
}
|
||||
}
|
||||
else{
|
||||
echo 'not a directory';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue