la fonction suivante prend un nom de répertoire en argument et retourne un array contenant la liste de tous les fichiers récursivement:
Download : getFiles.sh
function getFiles($directory) { // Try to open the directory if($dir = opendir($directory)) { // Create an array for all files found $tmp = Array(); // Add the files while($file = readdir($dir)) { // Make sure the file exists if($file != "." && $file != ".." && $file[0] != '.') { // If it's a directory, list all files within it if(is_dir($directory . "/" . $file)) { $tmp2 = getFiles($directory . "/" . $file); if(is_array($tmp2)) { $tmp = array_merge($tmp, $tmp2); } } else { array_push($tmp, $directory . "/" . $file); } } } // Finish off the function closedir($dir); return $tmp; } }
fonction récupérée sur php.net.