note 86457 modified in class.dir by danbrown

From: Date: Mon, 20 Oct 2008 13:48:05 +0000
Subject: note 86457 modified in class.dir by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-145508@lists.php.net to get a copy of this message
That's the way, I'm storing recursive dirs to an array. <?php public static function getTreeFolders($sRootPath = UPLOAD_PATH_PROJECT, $iDepth = 0) { $iDepth++; $aDirs = array(); $oDir = dir($sRootPath); while(($sDir = $oDir->read()) !== false) { if($sDir != '.' && $sDir != '..' && is_dir($sRootPath.$sDir)) { $aDirs[$iDepth]['sName'][] = $sDir; $aDirs[$iDepth]['aSub'][] = self::getTreeFolders($sRootPath.$sDir.'/',$iDepth); } } $oDir->close(); return empty($aDirs) ? false : $aDirs; } ?> --was-- That's the way, I'm storing recursive dirs to an array. <?php public static function getTreeFolders($sRootPath = UPLOAD_PATH_PROJECT, $iDepth = 0) { $iDepth++; $aDirs = array(); $oDir = dir($sRootPath); while(($sDir = $oDir->read()) !== false) { if($sDir != '.' && $sDir != '..' && is_dir($sRootPath.$sDir)) { $aDirs[$iDepth]['sName'][] = $sDir; $aDirs[$iDepth]['aSub'][] = self::getTreeFolders($sRootPath.$sDir.'/',$iDepth); } } $oDir->close(); return empty($aDirs) ? false : $aDirs; } http://php.net/manual/en/class.dir.php

« previous php.notes (#145508) next »