note 79216 deleted from function.readdir by ezyang

From: Date: Thu, 15 Nov 2007 21:34:00 +0000
Subject: note 79216 deleted from function.readdir by ezyang
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-132331@lists.php.net to get a copy of this message
Note Submitter: singh206 at gmail dot com Reason: useless ---- A simple recursive method for getting ONLY the final directories from some path. var $rootDir = '/RootFolder'; print_r($this->getFinalDirs($this->rootDir)); function getFinalDirs($root) { $result = $this->getNext($root); } function getNext($path) { $handle = opendir($path); if($handle) { $dirs = array(); while (false!==($dir=readdir($handle))) { if ($dir!='.'&&$dir!='..'&& $dir!='.DS_Store') { if(is_dir($path.'/'.$dir)) { $this->getNext($path.'/'.$dir); } else { array_push($dirs, $dir); break; } } } } return $dirs; }

« previous php.notes (#132331) next »