Revision: 15488
Updated Code
at July 8, 2009 16:43 by iloveitaly
Updated Code
function listdir($directory, &$list = array(), $base = '') { $iterator = new DirectoryIterator($directory); foreach($iterator as $file) { $name = $file->getFilename(); if($name[0] != '.') { if($file->isDir()) { listdir($directory.'/'.$name, &$list, $name.'/'); } else { $list[] = $base.$name; } } } return $list; }
Revision: 15487
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 7, 2009 14:43 by iloveitaly
Initial Code
function listdir($dir) { $dir = new DirectoryIterator($dir); $list = array(); foreach($dir as $file) { if(!$file->isDot() && !$file->isDir() /* && preg_match("/.jpe?g$/",$file->getFilename()) */) { $list[] = $file->getFilename(); } } return $list; }
Initial URL
Initial Description
Like python's os.listdir
Initial Title
Get List of Files in Directory
Initial Tags
list, array, files, directory
Initial Language
PHP