Get a List of Folders and/or Files





9
Date Submitted Fri. Oct. 14th, 2005 5:06 PM
Revision 1 of 1
Helper lilleman
Tags Files | Folders | List | PHP
Comments 1 comments
Get a List of Folders and/or Files
<?php

function listFolder($folder, $types = 0)
{
  $functions = array(
      1 => 'is_dir',
      2 => 'is_file'
    );
 
  $folderList = array();
 
  foreach( glob( "$folder/*" ) as $currentItem )
  {
    if( $types == 1 or $types == 2 )
    {
      if( $functions[$types]($currentItem) )
        $folderList[] = basename($currentItem);
    }
    else $folderList[] = basename($currentItem);
  }
 
  return $folderList;
}

?>

Erik Riklund

phofer.com

Comments

Comments Output?
Sat. Mar. 11th, 2006 5:23 PM    Helper Scriptsentials

Voting