From: jumpin-banana Date: Tue, 25 May 2010 10:45:04 +0000 (+0200) Subject: recursive read dir function X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=bfe30a91ea12040f9f6cd1758db84a734d8d807a;p=dolphin.git recursive read dir function --- diff --git a/single-functions/random-string-AZ09.php b/single-functions/random-string-AZ09.php index 0cd5705..faddc61 100644 --- a/single-functions/random-string-AZ09.php +++ b/single-functions/random-string-AZ09.php @@ -19,6 +19,7 @@ /** * create a random A-Z 0-9 string with the given length + * @author banana mail@bananas-playground.net * @param string $lentgh Default 5 * @return string The random string */ @@ -27,7 +28,7 @@ function randomAZ09($length=5) { for ($i=0; $i<$length; $i++) { $d = rand(1,30)%2; $str .= $d ? chr(rand(65,90)) : chr(rand(48,57)); - } + } return $str; } diff --git a/single-functions/read-dir-recursive.php b/single-functions/read-dir-recursive.php new file mode 100644 index 0000000..9b4f998 --- /dev/null +++ b/single-functions/read-dir-recursive.php @@ -0,0 +1,43 @@ +. + */ + +/** +* return recursive all data from the given directory +* @author banana mail@bananas-playground.net +* @param string $directory The directory to read +* @return array $files +*/ +function getSubFiles($directory) { + $files = array(); + + $dh = opendir($directory); + while(false !== ($file = readdir($dh))) { + if($file[0] ==".") continue; + + if(is_file($directory."/".$file)) { + array_push($files, $directory."/".$file); + } + else { + $files = array_merge($files, getSubFiles($directory."/".$file)); + } + } + closedir($dh); + return $files; +} +?>