satishgaudo.com

Understanding technology

Function to get the recursive folder structure of the destionation folder

/**
* getDirStructure
* get the recursive folder structure of the destionation folder
* @param string $path folder path
* @param array array resultant folders and files
* @access public
*/
public function getDirStructure($path, &$a, $sOriginalZipFilepath){
$aDir=array();
$aFiles=array();
$nd=0;
$nf=0;
$hndl=opendir($path);
while($file=readdir($hndl)){
if ($file =='.' || $file=='..') continue;
if (is_dir($path.'/'.$file)){
$aDir[$nd++]=$file;
}
else{
$aFiles[$nf++]=$file;
}
}
closedir($hndl);
$n=1;
for ($i=0;$i<count($aDir);$i++){
$this->getDirStructure($path.'/'.$aDir[$i].'/', $a[$n]);
$a[$n++][0]=str_replace("//","/",$path.$aDir[$i]);
}
for ($i=0;$i<count($aFiles);$i++){
$a[$n++]=str_replace("//","/",$path.$aFiles[$i]);
}
}
Bookmark and Share
Categories: PHP
twmujczf at 23:50 on 14 July 2009

thanks . i was searching for this code

Vaibhav at 11:20 on 29 January 2010

Hi Satish,
Good work dude …