edoceo: Latin "to inform fully, instruct thoroughly"

PHP - Directory Listing


The function below will return a sorted array of directories & files in the requested directory. No hidden (/^./) files are listed. Copy and paste away.

function dir_list($dir)
{
  $dl = array();
  if ($hd = opendir($dir))
  {
    while ($sz = readdir($hd)) { if (preg_match("/^\./",$sz)==0) $dl[] = $sz; }
    closedir($hd);
  }
  asort($dl);
  return $dl;
}
XHTML 1.1. and CSS2.1/3 © 1999-2008 Edoceo, Inc.
Edit this Page