/** * http://prendreuncafe.com/blog/post/2005/07/19/218-lister-recursivement-le-contenu-d-un-repertoire-en-php * @param unknown_type $path * @param unknown_type $full_list */ static function recursive_dir_content($path = '.', $full_list = false, $datasFormat = null) { $out = array(); $i = 0; $path = substr($path, strlen($path) - 1, strlen($path)) !== DS ? $path . DS : $path; if (!is_dir($path) || !($handle = @dir($path))) { trigger_error(DS . $path . DS . " doesn't exists or is not a valid directory", E_USER_ERROR); } else { while ($entry = $handle->read()) { if ($full_list == true || $entry !== "." && $entry !== "..") { $path_to_entry = $path . $entry; if ($entry !== '.' && $entry !== '..' && @is_dir($path_to_entry)) { $out[$entry] = FileAndDir::recursive_dir_content($path_to_entry, $full_list, $datasFormat); } else { $rootPath = $path_to_entry; $pathToWww = str_replace(ROOT, BASE_URL, $rootPath); $wwwPath = str_replace(DS, '/', $pathToWww); if (!isset($datasFormat)) { $out[$entry]['root'] = $rootPath; $out[$entry]['www'] = $wwwPath; } else { if ($datasFormat == 'root') { $out[$entry] = $rootPath; } else { if ($datasFormat == 'www') { $out[$entry] = $wwwPath; } } } } } } } return $out; }