i want to write file scan script
this script must search in lot's of folders and make list from files
i wrote this script , but return not working
function checkdir($dir) {
$file_array = array();
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $key => $object) {
if ($object != "." && $object != "..") {
if (filetype($dir."/".$object) == "dir") {
// folder loop , try find files again
checkdir($dir."/".$object);
//$file_array[] = 'dir';
} else {
$file_array[] = $dir."/".$object;
//echo $dir."/".$object.'<br>';
}
}
}// end foreach
//reset($objects);
}
return $file_array;
}
as you can see in else condition i wrote $file_array[] = $dir."/".$object; it's printing value but can not store value into array
checkdir()recursive calls, so this function will only ever return the contents of the top-level director you pass in. Everything else is basically useless, since you iterate all the sub-directories then throw away the results.$results[] = checkdir(...);-type stuff.