merge from qinghaihu branch, add recursive dir function
This commit is contained in:
parent
8eb4c55d9c
commit
4e42811648
|
@ -33,5 +33,43 @@ class mydir{
|
|||
function getLast()
|
||||
{
|
||||
return $this->list[count($this->list)-1];
|
||||
}
|
||||
|
||||
function array_flat($array)
|
||||
{
|
||||
foreach($array as $a)
|
||||
{
|
||||
if(is_array($a))
|
||||
{
|
||||
$tmp = array_merge($tmp, $this->array_flat($a));
|
||||
}else {
|
||||
$tmp[] = $a;
|
||||
}
|
||||
}
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
function recursive($dir)
|
||||
{
|
||||
$files = array();
|
||||
if ($handle = opendir($dir))
|
||||
{
|
||||
while (false !== ($file = readdir($handle)))
|
||||
{
|
||||
if ($file != "." && $file != "..")
|
||||
{
|
||||
if(is_dir($dir.'/'.$file))
|
||||
{
|
||||
$dir2 = $dir.'/'.$file;
|
||||
$files[]=$dir2.'/';
|
||||
$files[] = $this->recursive($dir2);
|
||||
} else {
|
||||
$files[] = $dir.'/'.$file;
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
return $this->array_flat($files);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue