note 82470 deleted from function.scandir by danbrown

From: Date: Thu, 28 Jan 2010 14:13:14 +0000
Subject: note 82470 deleted from function.scandir by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-165440@lists.php.net to get a copy of this message
Note Submitter: Daniel ---- recursive callback "scanDirectories" did not work for me. So I changed it to: function scanDirectories($rootDir, $allowext, &$allData = array()) { $dirContent = scandir($rootDir); foreach($dirContent as $key => $content) { if ($content == '.' || $content == '..') continue; $path = $rootDir . DIRECTORY_SEPARATOR . $content; $ext = substr($content, strrpos($content, '.') + 1); if(in_array($ext, $allowext) && is_file($path) && is_readable($path)) { $allData[] = $path; } else if(is_dir($path) && is_readable($path)) { // recursive callback to open new directory scanDirectories($path, $allowext, $allData); } // else unreadable hell } return $allData; }

« previous php.notes (#165440) next »