Make WordPress Core


Ignore:
Timestamp:
06/16/2008 09:08:49 PM (16 years ago)
Author:
mdawaffe
Message:

crazyhorse: merge with trunk [8072:8102]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/crazyhorse/wp-admin/includes/file.php

    r8053 r8103  
    4141
    4242    return $real_file;
     43}
     44//$folder = Full path to folder
     45//$levels = Levels of folders to follow, Default: 100 (PHP Loop limit)
     46function list_files( $folder = '', $levels = 100 ) {
     47    if( empty($folder) )
     48        return false;
     49
     50    if( ! $levels )
     51        return false;
     52
     53    $files = array();
     54    if ( $dir = @opendir( $folder ) ) {
     55        while (($file = readdir( $dir ) ) !== false ) {
     56            if ( in_array($file, array('.', '..') ) )
     57                continue;
     58            if ( is_dir( $folder . '/' . $file ) ) {
     59                $files2 = list_files( $folder . '/' . $file, $levels - 1);
     60                if( $files2 )
     61                    $files = array_merge($files, $files2 );
     62                else
     63                    $files[] = $folder . '/' . $file . '/';
     64            } else {
     65                $files[] = $folder . '/' . $file;
     66            }
     67        }
     68    }
     69    @closedir( $dir );
     70    return $files;
    4371}
    4472
Note: See TracChangeset for help on using the changeset viewer.