john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

list files in dir

<?php

//2010-06-09 john pfeiffer
//return a list of files from the directory (parameter)

function list_files_in_dir( $source )
{
    set_time_limit(60);     //prevent an endless listing, critical error after 60 seconds

    while (false !== ($file = readdir( $source ) )  )
    {
        if( $file != "." && $file != ".." ) //don't test the root directories
        {
            if( is_file($file) )
            {   $filelist[] = $file;    }
        }
    }
    return $filelist;
}

?>

  • « pop email with yahoo account thunderbird
  • find »

Published

Jun 9, 2010

Category

php

~46 words

Tags

  • dir 4
  • files 16
  • in 17
  • list 23
  • php 82