Gerard-Meier

Count lines of code in .cs files.

Jun 4th, 2011
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.37 KB | None | 0 0
  1. <?php
  2.  
  3. function countLines($path) {
  4.     $num   = 0;
  5.     foreach(scandir($path) as $file) {
  6.         if(substr($file, -3, 3) == '.cs') {
  7.             $num += count(file($path . DIRECTORY_SEPARATOR . $file));
  8.         } else if(is_dir($path . DIRECTORY_SEPARATOR . $file) && substr($file, -1) != '.') {
  9.             $num += countLines($path . DIRECTORY_SEPARATOR . $file);
  10.         }
  11.     }
  12.    
  13.     return $num;
  14. }
  15.  
  16. ?>
Advertisement
Add Comment
Please, Sign In to add comment