From bfe30a91ea12040f9f6cd1758db84a734d8d807a Mon Sep 17 00:00:00 2001 From: jumpin-banana Date: Tue, 25 May 2010 12:45:04 +0200 Subject: [PATCH] recursive read dir function --- single-functions/random-string-AZ09.php | 3 +- single-functions/read-dir-recursive.php | 43 +++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 single-functions/read-dir-recursive.php 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; +} +?> -- 2.39.5