I have a folder in my webserver that contains 81633 files in. I can see that by using the command: ls | wc -l
When I use scandir function it returns me only 80476 files :
$files = scandir($_SERVER['DOCUMENT_ROOT'] . "/assets/doc/bons/");
echo count($files);
The same result with :
$d = new DirectoryIterator($dir) or die("getFileList: Failed opening directory $dir for reading");
$cnt = 0;
foreach($d as $fileinfo) {
$cnt++;
}
echo $cnt;
result: 80476 files
All files have the same permissions. Is there some kind on limitation on PHP side or on file system side? Any help would be appreciated.
ls | wc -l
is not the right way to count files.
See also: https://unix.stackexchange.com/questions/113463/use-of-ls-with-wc-command