Reputation: 555
Does any one know how to scan directory recursively in php ?
$fileslist = array();
function readRecursive($dirname) {
global $fileslist;
$dir = scandir($dirname);
foreach ($dir as $f) {
if($f != "." && $f != ".." && $f != ".DS_Store") {
if(is_dir($dirname.DIRECTORY_SEPARATOR.$f)) {
$dname = $dirname.DIRECTORY_SEPARATOR.$f;
readRecursive($dname);
} else {
$fileslist[] = $dirname.DIRECTORY_SEPARATOR.$f;
}
}
}
}
following code doesn't work any idea Thanks in advance
Upvotes: 0
Views: 497
Reputation: 345
First check it your php version. this function is available only above php 5.0
Upvotes: 2