Basically I need to return the number of files from a directory, I was given a function to do way more than this but at the moment I seem to have written myself an infinite loop:
function get_files($section, $res=array()) {
$tfile = 0;
$dirs = array("/hsphere/local/home/pics/$section/" );
echo "\n\nTOTAL FILES: ".$tfile."\n\n";
if($id = opendir($dir)) {
while(false !== ($arch = readdir($id))){
if($arch != "." && $arch != "..") {
if(is_dir($dir.$arch)) {
$res = get_files($dir.$arch."/", $res);
}
else {
$res[] = $dir.$arch;
}
}
}
closedir($id);
}
foreach($dirs as $d) {
$files = get_files($girl);
foreach($files as $file) {
$tfile++;
}
}
return $tfile;
}