]> 91.132.146.200 Git - dolphin.git/commitdiff
read recursive dir with php The RecursiveIterator interface
authorBanana <johannes.kessler@bechtle.com>
Fri, 8 Feb 2013 09:42:26 +0000 (10:42 +0100)
committerBanana <johannes.kessler@bechtle.com>
Fri, 8 Feb 2013 09:43:35 +0000 (10:43 +0100)
single-functions/recursive-dir-with-DirectoryIterator.php [new file with mode: 0644]

diff --git a/single-functions/recursive-dir-with-DirectoryIterator.php b/single-functions/recursive-dir-with-DirectoryIterator.php
new file mode 100644 (file)
index 0000000..45bfe25
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+/**
+ *  dolphin. Collection of useful PHP skeletons.
+ *  Copyright (C) 2013  Johannes 'Banana' Keßler
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
+ *
+ * You should have received a copy of the
+ * COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+ * along with this program.  If not, see http://www.sun.com/cddl/cddl.html
+ */
+
+/**
+* return recursive all data from the given directory
+* @see http://www.php.net/manual/de/class.directoryiterator.php
+* @author banana mail@bananas-playground.net
+* @param string $directory The directory to read
+* @return array $files
+*/
+function readDirRecusrive($directory) {
+       $files = array();
+
+       $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('../'.STATIC_CACHE_PATH, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST);
+
+       foreach ($it as $file) {
+               $files[] = $file->getPathName();
+       }
+       
+       return $files;
+}
+?>
\ No newline at end of file