if ($handle = opendir('/path/to/directory/')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo "$file\n"; } } closedir($handle); }This code reads all files and directories in the specified directory one by one and prints the file names that are not . and .. directories. Package Library: PHP Standard Library.