note 41294 added to function.readdir
| From: | juanma at teslg dot com | Date: | Tue, 06 Apr 2004 00:13:31 +0000 |
| Subject: | note 41294 added to function.readdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-67675@lists.php.net to get a copy of this message | ||
This is a recursive function using readdir. It creates an Dir tree called Directorio on memory.
class Directorio
{
var $path="";
var $arrPathFich=array();
function Directorio()
{
if(func_num_args()==1)
{
$arr=func_get_args();
$obj=$arr[0];
$this->path=$obj->path;
$this->arrPathFich=$obj->arrPathFich;
}
}
}//Directorio
/* *** FUNCIONES *** */
function getArbolDir($dir)
{
$direct=new Directorio();
$direct->path=$dir;
$i=0;
$dir.='/';
if(is_dir($dir))
{
$pdir=opendir($dir);
while(FALSE !== ($nomfich=readdir($pdir)))
{
if($nomfich!="." && $nomfich!="..")
if(is_dir($dir.$nomfich))
$direct->arrPathFich[$i++]=new Directorio(getArbolDir($dir.$nomfich));
else
$direct->arrPathFich[$i++]=$dir.$nomfich;
}
closedir($pdir);
}
return $direct;
}//getArbolDir
----
Manual Page -- http://www.php.net/manual/en/function.readdir.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41294
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41294&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41294&report=yes
Search -- http://master.php.net/manage/user-notes.php