note 41294 deleted from function.readdir by tularis

From: Date: Sun, 13 May 2007 19:05:30 +0000
Subject: note 41294 deleted from function.readdir by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126542@lists.php.net to get a copy of this message
Note Submitter: juanma at teslg dot com ---- 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

« previous php.notes (#126542) next »