note 94082 deleted from function.scandir by danbrown

From: Date: Thu, 15 Oct 2009 15:32:23 +0000
Subject: note 94082 deleted from function.scandir by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-161769@lists.php.net to get a copy of this message
Note Submitter: laurent dot eyraud4 at free dot fr Reason: non-english ---- Bonjour, J'ai fait une modification pour obtenir la liste récursive des fichiers dans un simple tableau. // La fonction F_scandir_recursive fourni dans un simple tableau la liste recursive des fichiers d'un directorie function F_scandir_recursive($directory){ $folderContents = array(); $directory = realpath($directory).DIRECTORY_SEPARATOR; foreach (scandir($directory) as $folderItem) { if ($folderItem != "." AND $folderItem != ".."){ if (is_dir($directory.$folderItem.DIRECTORY_SEPARATOR)){ $files_table = Array(); $files_table = F_scandir_recursive( $directory.$folderItem.DIRECTORY_SEPARATOR); foreach($files_table as $file ){ $folderContents[] = $folderItem.DIRECTORY_SEPARATOR.$file; } }else{ // c'est un fichier $folderContents[] = $folderItem; } } } return $folderContents; } On peut l'appeler define('DIRECTORY_SEPARATOR=', '/'); $files_table = F_scandir_recursive("test_direcorie"); foreach($files_table as $file ){ echo "file=$file,<br>"; }

« previous php.notes (#161769) next »