Last active
August 31, 2020 03:24
-
-
Save trongle/46c3b39c48d98ba3093010c8e111342d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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); | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Include files in a specific directory with recursion supported.