<?php
$dir = "/tmp/";
$righe = 0;
function conta_righe($dir){
global $righe;
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if(is_file($dir . $file)){
$righe += count(file($dir . $file));
}else{
if($file != '..' && $file != '.'){
conta_righe($dir.'/'.$file.'/');
}
}
}
closedir($dh);
}
}
}
conta_righe($dir);
echo $righe;
?>