-4

我在这样的目录上使用 php dir() 函数:

/videos/1137
/videos/1137/0
/videos/1137/1
/videos/1137/2
/videos/1137/3
/videos/1137/4

代码以递归方式运行,但不选择某些目录

结果就像

READING /videos/1137
READING /videos/1137/2
READING /videos/1137/3

尽管所有文件夹都具有相同的权限,甚至用户/组也是相同的。

php dir() 函数中是否存在一些可能导致此问题的缺陷?

4

1 回答 1

2

I have no idea what you're doing in your code, since you haven't shown us any!

But here's a bit of code that will list all directories of a given folder, hopefully you can take it as inspiration for your own code.

<?php
function scan_videos(&$array, $path)
{
    $files = glob($path.'/*');
    foreach ($files as $file)
    {
        if (is_dir($file))
        {
            $array[] = $file;
            scan_videos($array, $file);
        }
    }
}

$directories = array();
scan_videos($directories, 'videos');
print_r($directories);
?>

This will output

Array
(
    [0] => videos/1137
    [1] => videos/1137/0
    [2] => videos/1137/1
    [3] => videos/1137/2
    [4] => videos/1137/3
    [5] => videos/1137/4
)
于 2013-06-28T08:20:30.693 回答