Skip to main content

Posts

Showing posts from July, 2011

php get files in a folder

<?php $results = array();     $directory = 'my_folder/files';         // create a handler for the directory     $handler = opendir($directory);     // open directory and walk through the filenames     while ($file = readdir($handler)) {       // if file isn't this directory or its parent, add it to the results       if ($file != "." && $file != "..") {         $results[] = $file;       }     }     // tidy up: close the handler     closedir($handler);         print_r($results); ?>