Getting the names of all files in a directory with PHP

Posted by Greelmo on Stack Overflow See other posts from Stack Overflow or by Greelmo
Published on 2010-05-27T16:31:09Z Indexed on 2010/05/27 16:31 UTC
Read the original article Hit count: 219

Filed under:
|
|
|
|

For some reason, I keep getting a '1' for the file names with this code:

if (is_dir($log_directory))
{
    if ($handle = opendir($log_directory))
    {
        while($file = readdir($handle) !== FALSE)
        {
            $results_array[] = $file;
        }
        closedir($handle);
    }
}

When I echo each element in $results_array, I get a bunch of '1's, not the name of the file. How do I get the name of the files?

© Stack Overflow or respective owner

Related posts about php

Related posts about file