I'm trying to get a list of directories in a path by using scandir
and removing the files from the array but I'm getting errors from my echo.
I'm using the code
$path = "Calltypes/";
$files = scandir($path);
$files = array_diff(scandir($path), array('.', '..'));
for($i = 0; $i < sizeof($files); $i++) {
if(!is_dir($files[$i]))
array_splice($files, $i, 1);
}
echo sizeof($files);
This is the echo output:
Notice: Undefined offset: 0 in C:\xampp\htdocs\index.php on line 32
2
The Calltypes/ path has 3 folders and 1 txt file.
Edit: line 32 is
if(!is_dir($files[$i]))