$dir = '/home/user/images/'; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { echo "filename: $file : filetype: " . filetype($dir . $file) . "\n"; } closedir($dh); } }In the above example, we are using opendir() to open a directory handle to the 'images' directory. Then we use the readdir() function in a while loop to read each file in the directory and display its name and file type. This function is part of the PHP core library, so no external package or library is required to use it.