note 82470 added to function.scandir

From: Date: Sat, 12 Apr 2008 06:55:57 +0000
Subject: note 82470 added to function.scandir
Groups: php.notes 
Request: Send a blank email to php-notes+get-138207@lists.php.net to get a copy of this message
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; } ---- Server IP: 69.147.83.197 Probable Submitter: 84.188.173.147 ---- Manual Page -- http://www.php.net/manual/en/function.scandir.php Edit -- https://master.php.net/note/edit/82470 Del: integrated -- https://master.php.net/note/delete/82470/integrated Del: useless -- https://master.php.net/note/delete/82470/useless Del: bad code -- https://master.php.net/note/delete/82470/bad+code Del: spam -- https://master.php.net/note/delete/82470/spam Del: non-english -- https://master.php.net/note/delete/82470/non-english Del: in docs -- https://master.php.net/note/delete/82470/in+docs Del: other reasons-- https://master.php.net/note/delete/82470 Reject -- https://master.php.net/note/reject/82470 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#138207) next »