Search Results

Search found 1 results on 1 pages for 'user661999'.

Page 1/1 | 1 

  • How to change a recursive function for count files and catalogues?

    - by user661999
    <?php function scan_dir($dirname) { $file_count = 0 ; $dir_count = 0 ; $dir = opendir($dirname); while (($file = readdir($dir)) !== false) { if($file != "." && $file != "..") { if(is_file($dirname."/".$file)) ++$file_count; if(is_dir($dirname."/".$file)) { ++ $dir_count; scan_dir($dirname."/".$file); } } } closedir($dir); echo "There are $dir_count catalogues and $file_count files.<br>"; } $dirname = "/home/user/path"; scan_dir($dirname); ?> Hello, I have a recursive function for count files and catalogues. It returns result for each catalogue. But I need a common result. How to change the script? It returns : There are 0 catalogues and 3 files. There are 0 catalogues and 1 files. There are 2 catalogues and 14 files. I want: There are 2 catalogues and 18 files.

    Read the article

1