Code:
<?php
function scanDirectories($rootDir, $allowext, $allData=array()){
$dirContent = scandir($rootDir);
foreach($dirContent as $key => $content){
$path = $rootDir.'/'.$content;
$ext = substr($content, strrpos($content, '') + 1);
if(in_array($ext, $allowext)) {
if(is_file($path) && is_readable($path)){
$allData[] = $path;}
elseif(is_dir($path) && is_readable($path)) {
// recursive callback to open new directory
$allData = scanDirectories($path, $allData);
} } }
return $allData;}
$rootDir = "www";
$allowext = array("zip","rar","html");
$files_array = scanDirectories($rootDir,$allowext);
print_r($files_array);
?>
Warning: scandir(www,www ) [function.scandi r]: The system cannot find the file specified. (code: 2) in C:\Zend\Apache2 \htdocs\CSV\exa mple.php on line 4
Warning: scandir(www) [function.scandi r]: failed to open dir: No such file or directory in C:\Zend\Apache2 \htdocs\CSV\exa mple.php on line 4
Warning: scandir() [function.scandi r]: (errno 2): No such file or directory in C:\Zend\Apache2 \htdocs\CSV\exa mple.php on line 4
Warning: Invalid argument supplied for foreach() in C:\Zend\Apache2 \htdocs\CSV\exa mple.php on line 5
Array ( )
please help ......:'(