Created
July 13, 2012 20:26
-
-
Save robotamer/3107221 to your computer and use it in GitHub Desktop.
Get php files in dir with recursive lambda callback function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* @param string $dir | |
* @return array | |
*/ | |
function get_php_files_in_dir($dir) | |
{ | |
$bin = array (); | |
$run = function(&$run, $dir, &$bin) { | |
if ($handle = opendir($dir)) { | |
while (false !== ($file = readdir($handle))) { | |
if ($file != "." && $file != "..") { | |
if (strpos($file, '.php') > 0) { | |
$bin[] = $dir . '/' . $file; | |
} elseif (is_dir($dir . '/' . $file)) { | |
$run($run, $dir . '/' . $file, $bin); | |
} | |
} | |
} | |
} | |
closedir($handle); | |
}; | |
$run($run, $dir, $bin); | |
return $bin; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment