Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mepawan
Last active April 7, 2017 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mepawan/b538ca8a6e5849ae8c40e579dbc89f47 to your computer and use it in GitHub Desktop.
Save mepawan/b538ca8a6e5849ae8c40e579dbc89f47 to your computer and use it in GitHub Desktop.
<?php
function _require_all($directory, $exclude_folders = array(), $exclude_extensions = array() ) {
if(is_dir($directory)) {
$scan = scandir($directory);
unset($scan[0], $scan[1]); //unset . and ..
foreach($scan as $file) {
if(is_dir($directory."/".$file)) {
if(in_array($file,$exclude_folders)){
continue;
}
_require_all($directory."/".$file);
} else {
if(in_array($ext, $exclude_extensions){
continue;
}
include_once($directory."/".$file);
}
}
}
}
@mepawan
Copy link
Author

mepawan commented Apr 7, 2017

Php code to all include recursively inside given directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment