I'm trying to scan folders recursively and store every *.h file found's path into an array.
function findfiles($input, &$array){
$dir = scandir($input);
foreach($dir as $file)
{
if ($file !== "." && $file !== "..")
{
if (is_file(realpath($file)) && substr($file, -2) === ".h")
{
array_push($array, realpath($file));
}
if (is_dir(realpath($file)) //I'M EVEN USING ABSOLUTE PATH
{
findfiles(realpath($file), $array);
}
}
}
}
$input="./"
$array = array();
findfiles($input, $array);
I guess this should work but function is_dir() returns FALSE for directories "./atest/AA" and "./atest/FolderInside" even if I have all permissions set.
drwxrwxrwx 2 root root 0 úno 14 18:46 AA
drwxrwxrwx 2 root root 0 úno 14 15:12 FolderInside
and works great with other folders "atest" and "test1" even they have the same permissions set.
drwxrwxrwx 2 root root 0 úno 14 18:46 atest
drwxrwxrwx 2 root root 0 úno 14 15:39 test1
Please why?