Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

http://bosaap.nl

« Newer Snippets
Older Snippets »
1 total  XML / RSS feed 

Word Count

Word count of current working dir.

        $url = getcwd();
        
        function listDeep($dir) {
                $out = array();
                $dbug = array();
                $ddir = scandir($dir);
                $nosho = array('..', '.', '.DS_Store', '', '.svn');
                foreach($ddir as $file) {
                        if(!in_array($file, $nosho)) {
                                if(@is_dir($dir . '/' .$file)) {
                                        $p = listDeep($dir . '/' . $file);
                                        foreach($p as $f) {
                                                $out[] = str_replace(' ', '\ ', $f);
                                        }
                                } else {
                                        $out[] = str_replace(' ', '\ ', $dir . '/' . $file);
                                }
                        }
                }
                return $out;
        }
        $g = implode(' ', listDeep($url));
        echo '
';
        echo 'Word count for: '. $url . "\n" .'   Lines   Words   Chars'. "\n";
        echo exec('wc '. $g) . '
';
« Newer Snippets
Older Snippets »
1 total  XML / RSS feed