Skip to content

Instantly share code, notes, and snippets.

@trongle
Last active August 31, 2020 03:24
Show Gist options
  • Select an option

  • Save trongle/46c3b39c48d98ba3093010c8e111342d to your computer and use it in GitHub Desktop.

Select an option

Save trongle/46c3b39c48d98ba3093010c8e111342d to your computer and use it in GitHub Desktop.
function include_files(string $path, $recursion = true)
{
$files = scandir($path);
foreach ($files as $fileName) {
if ($fileName == '.' || $fileName == '..') {
continue;
}
$file = "$path/$fileName";
if (is_file($file)) {
require_once $file;
}
if (is_dir($file) && $recursion) {
include_files($file);
}
}
}
@trongle
Copy link
Author

trongle commented Aug 31, 2020

Include files in a specific directory with recursion supported.

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