The Deployer

May 18, 2009

Listing files in a directory with PHP

Filed under: PHP — Tags: , — Lucian Daniliuc @ 10:27

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
)

Powered by WordPress