Listing files in a directory with PHP

Listing the files in a directory in PHP is as simple as 1 line:

$aList = scandir( '/tmp' );
print_r( $aList );

This will retrieve all the files in the specified directory (including “.” and “..”):

Array
(
    [0] => .
    [1] => ..
    [2] => uioeng34890gn34.dat
)

Leave a Reply