Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP中,为什么scandir调用返回错误数量的文件?_Php_Debugging_Directory_Hierarchical_Scandir - Fatal编程技术网

在PHP中,为什么scandir调用返回错误数量的文件?

在PHP中,为什么scandir调用返回错误数量的文件?,php,debugging,directory,hierarchical,scandir,Php,Debugging,Directory,Hierarchical,Scandir,在今天日期的文件下,我有一个单独的其他目录,但是当我询问scandir返回的数组的计数时,我总是得到3。我已经通过echo调用检查了这一点,其中countscandir$dir总是返回3。$dir中有子文件,但有4个子文件。这可能与此有关吗?如何修复此错误?谢谢你能提供的任何帮助;我真的很感激从更有经验的程序员那里得到建议 使用scandir,您始终可以获得当前目录。和父目录。。。您可以检查是否打印了scandir的结果。所以你只需要减去斯堪的纳维亚数的2 根据文件: for($inst

在今天日期的文件下,我有一个单独的其他目录,但是当我询问scandir返回的数组的计数时,我总是得到3。我已经通过echo调用检查了这一点,其中countscandir$dir总是返回3。$dir中有子文件,但有4个子文件。这可能与此有关吗?如何修复此错误?谢谢你能提供的任何帮助;我真的很感激从更有经验的程序员那里得到建议

使用scandir,您始终可以获得当前目录。和父目录。。。您可以检查是否打印了scandir的结果。所以你只需要减去斯堪的纳维亚数的2

根据文件:

    for($instancesFiles=1;$instancesFiles<count(scandir("Articles/".date('y-m-d').""));$instancesFiles++){
//For each file inside the directory for today's articles, each of which corresponds to an instance of the "article" class...
        $dir="Articles/".date("y-m-d")."/".$instancesFiles."";
        $artProps=scandir($dir);
    //Retrieve an array of its interior files, each of which corresponds to a property of the aforementioned instance
$dir中有子文件,但有4个子文件。能够 那跟它有关系吗

=>不,scandir不是递归的

$dir    = '/tmp';
$files1 = scandir($dir);

print_r($files1);

Array
(
    [0] => .
    [1] => ..
    [2] => bar.php
    [3] => foo.txt
    [4] => somedir
)