note 95458 modified in function.readdir by thiago

From: Date: Mon, 04 Jan 2010 14:09:31 +0000
Subject: note 95458 modified in function.readdir by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-164607@lists.php.net to get a copy of this message
this simple function will index the directories and sub-directories of a given dir <?php function get_dirs($dir){ global $dirs; if (!isset($dirs)){$dirs = '';} if(substr($dir,-1) !== '\\'){$dir .= '\\';} if ($handle = opendir($dir)){ while (false !== ($file = readdir($handle))){ if (filetype($dir.$file) === 'dir' && $file != "." && $file != ".."){ clearstatcache(); $dirs .= $file . "\n"; get_dirs($dir . $file); } } closedir($handle); } return $dirs; } ?> --was-- this simple function will index the directories and sub-directories of a given dir function get_dirs($dir){ global $dirs; if (!isset($dirs)){$dirs = '';} if(substr($dir,-1) !== '\\'){$dir .= '\\';} if ($handle = opendir($dir)){ while (false !== ($file = readdir($handle))){ if (filetype($dir.$file) === 'dir' && $file != "." && $file != ".."){ clearstatcache(); $dirs .= $file . "\n"; get_dirs($dir . $file); } } closedir($handle); } return $dirs; } http://php.net/manual/en/function.readdir.php

« previous php.notes (#164607) next »