note 79218 deleted from function.readdir by danbrown

From: Date: Thu, 25 Feb 2010 20:32:33 +0000
Subject: note 79218 deleted from function.readdir by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-166371@lists.php.net to get a copy of this message
Note Submitter: singh206 at gmail dot com ---- Oops, made a few syntactical errors in the last example of getting only the final directory paths from a root dir. PHP 4 OO. var $rootDir = '/SOME DIRECTORY'; print_r($this->getFinalDirs($this->rootDir)); function getFinalDirs($root) { return $this->getNext($root); } function getNext($path) { static $dirs = array(); $handle = opendir($path); if($handle) { while (false!==($dir=readdir($handle))) { if ($dir!='.'&&$dir!='..'&& $dir!='.DS_Store') { if(is_dir($path.'/'.$dir)) { $this->getNext($path.'/'.$dir); } else { array_push($dirs, $path); break; } } } } return $dirs; }

« previous php.notes (#166371) next »