Return to Snippet

Revision: 55280
at February 1, 2012 06:30 by duzenz


Initial Code
<?php
$folderCount = $fileCount = 0;
//. means current directory
//if you wanna a learn a folders inside use opendir('path')
if ($handle = opendir('.')) {
    while (false !== ($entry = readdir($handle))) {
        if ($entry != "." && $entry != "..") {
            if (is_dir($entry)) {
                echo "Folder => " . $entry . "<br>";
                $folderCount++;
            } else {
                echo "File   => " . $entry . "<br>";
                $fileCount++;
            }
        }
    }
    echo "<br>==============<br>";
    echo "Total Folder Count : " . $folderCount . "<br>";
    echo "Total File Count : " . $fileCount;
    closedir($handle);
}
?>

Initial URL

                                

Initial Description
Getting files, folders, file count, folder count in a directory with php and writing them to a web page

Initial Title
Getting files, folders, file count, folder count in a directory with php

Initial Tags
php, file, directory

Initial Language
PHP